Prevent local changes by clicking on Git

I cloned a repository, and the master branch in my repo is tracking origin/master . I created a work branch and changed some configuration files specific to my dev machine to make the application work.

My usual workflow is going to the master branch, merging the changes made in the work branch, and push those changes upstream. The problem is that I do not want my specific chanages to be clicked. When I merge the work branch into master , these changes are also merged.

The only solution I have found so far is not to commit these changes to work , but this is not a satisfactory solution.

+61
git git-push
Jan 31 '10 at 22:52
source share
4 answers

If you want to prevent these local configuration files from being committed (and therefore also pushing), you can use git update-index --assume-unchanged . Files marked with this flag will be considered immutable (until you reset with the flag with -no-suppose-no change)

+79
Jan 31 '10 at 23:23
source share

If the files are no longer being tracked, you can add them to the .gitignore file in the local repository, otherwise you will need to use git update-index --assume-unchanged , as Mauricio said.

See below for more information on .gitignore files:

http://git-scm.com/docs/gitignore

+8
Jan 31 '10 at 23:32
source share

One way to solve this problem is to "pour cherry" every change from your work branch to the master before you move upstream. I used a technique in which I include a word, such as NOCOMMIT, in a commit message only for local changes, and then use a shell script like this:

 #!/bin/sh BRANCH=`git branch | grep ^\\* | cut -d' ' -f2` if [ $BRANCH != "master" ]; then echo "$0: Current branch is not master" exit 1 fi git log --pretty=oneline work...master | grep -v -E '(NOCOMMIT|DEBUG):' | cut -d' ' -f1 | tac | xargs -l git cherry-pick 

This cherry selects every change that is not marked by NOCOMMIT (or DEBUG) in the leading branch.

+5
Jan 31 '10 at 23:20
source share

You need a .gitignore file and add your entire configuration file to the .gitignore file.

Once your .gitignore file is ready, you may need to delete your configuration files from the cache

Here's the command:

 (Assume you use linux) vi .gitignore //Add all your config file inside //run the following command to remove your config file from GIT cache if your config files is already track by GIT git rm --cached myconfig.php 
0
Dec 21 '10 at 4:02
source share



All Articles