Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore local file changes

Tags:

git

I've tried both

git update-index --assume-unchanged config/myconfig 

and

editing .git/info/exclude and adding config/myconfig

however when I do git pull I always get:

Updating 0156abc..1cfd6a5 error: Your local changes to the following files would be overwritten by merge: config/myconfig Please, commit your changes or stash them before you can merge. Aborting

What am I missing?

like image 911
user2395365 Avatar asked Jul 27 '14 17:07

user2395365


2 Answers

git pull wants you to either remove or save your current work so that the merge it triggers doesn't cause conflicts with your uncommitted work. Note that you should only need to remove/save untracked files if the changes you're pulling create files in the same locations as your local uncommitted files.

Remove your uncommitted changes

Tracked files

git checkout -f 

Untracked files

git clean -fd 

Save your changes for later

Tracked files

git stash 

Tracked files and untracked files

git stash -u 

Reapply your latest stash after git pull:

git stash pop 
like image 148
Nick McCurdy Avatar answered Sep 23 '22 02:09

Nick McCurdy


You most likely had the files staged.

git add src/file/to/ignore 

To undo the staged files,

git reset HEAD 

This will unstage the files allowing for the following git command to execute successfully.

git update-index --assume-unchanged src/file/to/ignore 
like image 33
Eric Avatar answered Sep 23 '22 02:09

Eric