简体   繁体   中英

how can I untrack files in a branch that is not my current branch

I have 2 git branches 'Master' and 'Work'.

I had been working on my 'Work' Branch for a while. In work I untracked all my *.png files and added *.png to my gitignore.

The master branch is still tracking *.png.

Now I can't checkout my master branch because git is complaining that my untracked files would be over written by checkout.

I can't checkout my master branch and merge my work branch into it.

How can I tell my master branch to stop tracking *.png.

I know you usually use rm -r --cached to remove files but I only know how to do that from the current branch.

You really need to move the files aside, checkout master and either repeat the changes there are better cherry-pick the removes/gitignore-additions into master, and then checkout your branch again and move the files back. That's the safest way (especially if you have changes to the PNGs).

使用.git / info / exclude如果您希望基于存储库的排除模式,则可以将其放入该特定存储库中名为.git / info / exclude或core.excludesfile的文件中

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM