How to ignore files and folders with pull requests to github in distinct git clones installations?
I have a problem with GitHub.
I use the remote repository on GitHub to download a copy into a server to make an installation of a software, but each server needs to make some changes to a file named
/www/inc/config.inc.php a other folders like
www/images/ because each installation is personalized.
The problem comes when I call the command “
git pull” to synchronize the different server installations with GitHub to get the new changes or versions because the file
www/inc/config.inc.php changes it’s content to the original one, or the one that is located on GitHub.
I’d like to say GitHub to not synchronize the
www/inc/config.inc.php file and the
/www/images folder on each server that I ran originally the
git clone command to make a new installation.
2 Solutions collect form web for “How to ignore files and folders with pull requests to github in distinct git clones installations?”
I first want to restate your problem to ensure that I understand correctly.
You have servers that need to have installations performed or updated if they exist. You have the installation files on github.
For new installations, you clone from github and then modify the /www/inc/config.inc.php file and /www/images folder.
When you perform updates, you push those updates to github, and then you want to pull those updates from github to your various servers, but don’t want to merge or overwrite the local changes.
Please comment if I have the scenario incorrect.
Assuming the above is correct, here is an approach to accomplishing this:
When you first clone the repo to the local server, create a branch before making your local changes. Always keep the local repo on the branch you created.
#clone the repo git clone git://github.com/you/yourproject.git #create and checkout a local working branch git checkout -b workingBranch #make your changes to configs and other directories freely ... #when you're done, add and commit those changes git add . git commit
When you have an update you want to pull to the local machine
#checkout the master branch git checkout master #pull to get the latest code git pull origin master #checkout the workingBranch again git checkout workingBranch #rebase to get the new changes on that branch git rebase master
This will temporarily roll back your changes that you made on your branch, get the latest commits from the master branch, and then “replay” your commits on top of the new changes.
Unless you intend to make modifications directly in the live server tree (
/www), commit them and push them back, you don’t need to pull directly from
Ie you don’t need
/www to be a Git repo.
You can pull into a clone of that repo on your server, and then rsync what you need in your live environment (still on your server).
In other words, you keep a strict separation between the git repo and the live tree.
That way, you control exactly what you need to update.