Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

git track, ignore, delete, untrack

I seem to have ballsed up my git repo by tracking a file, later ignoring it and then deleting it. The thing is, I want the file to be present in a remote repository (the live site), but just don't want to track.

Now my master branch is trying to remove all the files from the repository, which I know will delete them on the remote branch when I push changes... I just want to untrack them, but cannot do that as they're already deleted on master and git rm -r --cached says 'did not match any files'.

How can I untrack these deleted files without removing them from the remote repository?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You just don't want to track a file, but you want to keep the file in the remote repository (non-bare).

Use this git command. After you do this, git stops checking the file for possible modifications.

git update-index --assume-unchanged  <filename>

At any time, you can track again by setting --no-assume-unchaged flag

git update-index --no-assume-unchanged  <filename>

These command do not affect the remote repository.

For more information: http://kar-git.blogspot.in/2012/11/how-to-set-git-to-ignore-few-files-like.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...