I have repository my team works on in which there are some files that are tracked but may be changed locally like .exe file which is an effect of compilation but should be checked in only when release is done. Another is makefile.mk in which I set some local option and rarely make changes I need to commit. Usually this file is different from repository version ant this is OK. So these files are tracked, cannot be put into .gitignore
but make git pull origin
cry for overwriting changes to these files ( error: Your local changes to the following files would be overwritten by merge ). I tried to put *.exe~
into .git/info/exclude
(as well as the .mk) and run git update-index --no-assume-unchanged that.exe
so git status
no longer shows them but pulling still fails, even with -f
. I read somewhere to use git update-index --skip-worktree
an I tried. Now no one knows how to update my repo.
How can I keep modified files which are tracked and make GIT ignore their changes locally?
Git cannot track and ignore a file on the same time; it doesn't make any sense.
Remove the files from Git ( git rm --cached that.exe makefile.mk
), add their names to .gitignore
and commit.
Make a copy of makefile.mk
(let's say makefile.mk.example
) provide sensible defaults for the values that change from one development environment to another and add it to the repository.
Document this change to let any developer know how to get their own makefile.mk
when they clone the repo.
for your first question, you could use the command.
git rm --cached <filename>
rm is for removal.
and for second question you can find the answer here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.