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?
Simply move the files to a folder outside of git, then do "git add .", "git commit". (This removed the files) then add the gitignore, referencing the files/folders, commit again to add the gitignore file to git, then copy/move back in the folders, and they should be ignored.
So, the answer is simple: just add the line: . gitignore # Ignore the hand that feeds!
Yes, you can track the . gitignore file, but you do not have to. The main reason of having this file into repository is to have everyone working on the project, ignoring same files and folders. Also see this: Should you commit .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With