I am using imgix module in drupal which is dependent on composer. When I run command drush composer-manage install, I can see imgix-php (a library of imgix) is downloaded in vendor directory. I have setup everything correctly and it works well in my localhost. Now I want to push them into github. I can see none of file of imgix-php is added in git and it is emty in github. Then I have see there is a file .gitignore in imgix-php where vendor is written. However, I have commented it out. But unable to add any files of imgix-php. If I commented out the line vendor of .gitignore and check the status, it shows me as:
On branch staging
Your branch is up-to-date with 'origin/staging'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: sites/all/vendor/imgix/imgix-php (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
Could tell me someone why I can't add them.
Have you actually added the imgix-php files after you commented the .gitignore file, using
git add /path/to/folder/*
or
git add --all /path/to/folder
?
Related
I have just begun learning the basics of Git.
I have installed Git locally and successfully integrated it to clone repos into my xampps/htdocs.
Now locally, in this repo I have moved all the files into the php_Basics folder. But when I try and commit to sync up with my GitHub repo it says no changes added to commit.
How do I commit the file restructure, and sync it to the GitHub repo?
Source:Reference
Details about github
Checklist------------------------------------
Move files to git cloned repository if not use git init then move files
configure git username
check status --- git status you will see changed files
git add file to staging for commit
git commit
git push
Note: if the editor for the commit message is finicky, you can start with a shorter commit message in command line:
cd /path/to/local/repo
git add .
git commit -m "my message"
git push -u origin master
I'm trying do to the following:
1) Create a new laravel project using:
sudo composer create-project laravel/laravel /var/www/html/laravel5`
2) Overwrite only the different files from github. I want to keep the following files and folders unchanged:
.env
.env.example
.gitattributes
.gitignore
vendor/
Clone from github is not working because the folder is not empty.
The only workaround that I found is:
create a new project
copy the files and folders that I want to another folder
clone the project from github
copy the files back to the folder
I'm using Xubuntu, Laravel 5.0 and Github.
Thanks in advance.
You should be able to do this via an all-git method rather than copy/paste from another directory. (I'm not sure why your workaround is a bad solution, though.)
The basic plan is:
Create a repository.
Checkout some bogus branch that you won't keep around.
Add the directories you want to keep to the index and commit them.
Force a checkout to the branch you want. It probably will need forcing because of the other things you didn't just commit.
Apply the patch of the recently created commit to your working directory.
And in commands:
cd /path/to/repo
git init
git branch temp-branch
git add .env && git add .env.example && git add .gitattributes && git add .gitignore && git add vendor/
git commit -m "Sustain Local Changes"
git remote add origin https://github.com/owner/repo
git fetch
git checkout -f master # Should detect origin/master. If it doesn't, just set a branch up manually. Replace master if that's not the branch you want.
git merge --no-commit --no-ff temp-branch
Personally, I find this a lot more ugly than your workaround.
I am trying to push my php app to Heroku and get the below error.
Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected.
I have read through all the previous posts which said that the PHP app should have a index.php in the root folder...which i do. When i do a "git ls-files" i get the index.php listed (with the name in lowercase).
steps i have performed so far are.
1. i have an application created on Heroku - stack:Cedar
2. git add the relevant files
3. git commit with a comment
4. git push heroku master -- this guy gives me the error.
git ls-files lists a file "index.php".
What am i missing this time?
I'm just starting out with Heroku and was encountering the same problem. Below is a description of what I did wrong.
Procfile
Make sure that the following statement is included in your Procfile:
web: vendor/bin/heroku-php-apache2 path/to/web/
Where path/to/web/ is the relative path to the directory that you want to publicly expose on the web. Make sure that the public directory contains an index.php file (e.g. path/to/web/index.php).
composer.json
In your composer.json directory (which should be in the base directory of the repository) make sure to include the Heroku PHP buildpack.
{
"require": {
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
If this statement was missing, then run composer update (./composer.phar update for me, because I downloaded composer and placed it in the base directory of my repository) so that Composer will fetch the package and install it into your vendor directory.
the issue was with an incorrect/incomplete .git directory. Deleting the old one and recreating it (git init) solved the problem.
try to run this on you heroku toolbelt
> heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
> git add .
> git git commit -am "add composer.json for PHP app detection"
> git push / git push heroku master
As a PHP developer I find myself working with Composer a lot. In the past it was on personal projects and such so I didn't have much problems with it, but now with Laravel 4 it's on project that require deploying and I'm in kind of a struggle to adapt my workflow.
All my projects are git repositories, thus per convention and because it's still quite buggy, like most developers I put the vendor directory in my .gitignore.
Now the problem is : I also use Git to deploy to the server, and by all logic the vendor directory is not uploaded as it's not tracked by the repository.
So my question is towards people that have worked with Composer and Git for longer than me : what is the best workflow to keep the server in sync ? How to track the vendor folder without really tracking it ?
I tried uploading it every time I update with Composer but some of my vendor folders are quite big and I can't manually upload 30Mb of files every time something updates.
I don't really know, how do you guys work it out ? I tried not ignoring the vendor folder but Git just messes it up, half are recognized as cloned repos and are just ignored anyway, etc.
UPDATE : Note that I'm on a shared host so I don't have access to the server's terminal.
The best way is to run composer install on the server after updating to the latest code. You should also make sure you commit your composer.lock file, which the server will then use to install (you should not run composer update on the server).
Capistrano (or Capifony if you are using Symfony2) is very useful for deployments with composer. You can trigger a deployment remotely and it will run a composer install in isolation so the site remains online until it has been deployed successfully. There are many other benefits such as retaining previous deployments and rolling back, copying old vendors before deployments, compiling assets etc. etc.
I'm working on something like this in the git post-receive hook on the server. This isn't tested and may be buggy, but you should get the idea.
#!/bin/bash
# get the updated composer.json
git checkout master -- composer.json
# only do this stuff if composer.json is different
# you could check this manually, or with git or cmp
cp composer.json tmp/composer.json
# may take a minute, but won't take the site down
(cd tmp; composer install --prefer-dist)
# this doesn't seem to be atomic
git checkout -f
# switch vendors over
# this isn't quite an atomic operation, but is very close
# you could probably do it with symlinks and "mv -Tf" to make it atomic
mv vendor vendor.old
mv tmp/vendor vendor
rm -r tmp vendor.old
Ideally all of the deploy (i.e. in this case the git checkout and the composer install) except one single mv would happen in isolation, outside of www. This doesn't work if you have untracked files (eg CMS uploads) in your working tree and rely on PHP's __FILE__ not resolving symlinks (due to this PHP bug).
This is an old question but in case anybody is looking a solution:
I slightly modify the #dave1010 answer to use git pull instead of git checkout--force
#!/bin/bash
# get only composer files
git fetch
git checkout origin/master -- composer.json
git checkout origin/master -- composer.lock
# make sure tmp is empty
rm -rf tmp
mkdir tmp
# copy the composer files to tmp
cp -r vendor tmp/vendor
cp composer.json tmp/composer.json
cp composer.lock tmp/composer.lock
# may take a minute, but won't take the site down
(cd tmp; composer install --no-scripts --verbose; cd ..)
# switch vendors over
rm -rf vendor_old
mv vendor vendor_old
mv tmp/vendor vendor
# update your code
git pull
# run again composer install. This time will print 'Nothing to install or update'
# but will execute pre/post scripts & generate autoload files
composer install --optimize-autoloader
There is maybe a better solution using capistrano/composer. But I like mine better.
You can use something like jenkins to ftp your files over this way you can direct jenkins to run composer install on the jenkins server and then ftp the files over.
This also allows you to ignore the vendor folder.
It does require a build server to be made and you would need to be able to execute commands vs the build server
The key is your composer.lock file. The composer.lock keeps track of exactly what packages (and versions) you have installed. When you deploy, send your composer.lock file up to the production server as well, and simply do a composer update. All the exact same package versions will be installed. With deployment software like Capistrano or Flightplan you can make the composer update step part of the process so it happens automatically.
I use git as my primary version control system, and have recently started using git on my CakePHP projects. This is my current .gitignore file:
app/tmp
vendors/
As used in the cakephp git repo, but this causes a bit more work for me when deploying the project to a server, because I have to go in and create all the app/tmp/ sub-directories by hand before they will work correctly. Is there a way to set it up to ignore the contents on these folders, but to still have them under git control so they appear when I clone the repo into the hoted directory?
I also have been having an issue with my git index being reset while I am working on it, which is causing me to have to do a lot more commits than should be necessary, any ideas on that also?
Git stores only files, not directories, so you can for example add a hidden file into that directory and commit it.
Remove app/tmp/ from .gitignore
touch app/tmp/.keep
git add app/tmp/.keep
git commit
Add app/tmp/ to .gitignore
As mentioned git only stores files, not directories. By default cake's .gitignore file ignores all contents in the tmp folder to prevent tmp files being added to your repository.
You can (and should) however do this after you create a project:
cd /my/app
git add -f tmp
which will do this:
$ git status
# On branch master
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: tmp/cache/models/empty
# new file: tmp/cache/persistent/empty
# new file: tmp/cache/views/empty
# new file: tmp/logs/empty
# new file: tmp/sessions/empty
# new file: tmp/tests/empty
As such your tmp folder structure is ready to be committed, but all other files in your tmp dir will (continue to) be ignored.
My .gitignore file.
tmp/*
[Cc]onfig/core.php
[Cc]onfig/database.php
webroot/files/
webroot/img/photos/
!empty
.DS_Store
If you'll notice I have !empty which saves me from creating .keep files all over which is so SVN ago. Lastly you'll also see that I use this config for both cakePHP 1.x and 2.x projects noted by the [Cc]. I have some folders setup that I store user files in so I always ignore them as well. Finally the .DS_Store ignores my MAC created thumbnail views for my project.