Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git track, ignore, delete, untrack

Tags:

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?

like image 984
Martin Petts Avatar asked Mar 20 '12 11:03

Martin Petts


People also ask

How do I ignore a tracked file in git?

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.

How do I Untrack Gitignore?

So, the answer is simple: just add the line: . gitignore # Ignore the hand that feeds!

Should git ignore be tracked?

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 .


1 Answers

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

like image 121
Karthik Bose Avatar answered Nov 19 '22 19:11

Karthik Bose