1

A previous poster wanted to track a file in one branch and not in another; I just want to not track it at all.

I used to have ".p4client" tracked in git, which turned out to be a mistake. So I deleted it from the repository, added the name to .gitignore, and recreated the file. Now it gets deleted when I switch branches -- but only some checkouts, not all. It appears to occur only when switching to 'master', not from, and not when going between dev branches.

How can I put an stop to this, and just keep the file around, untracked?

Community
  • 1
  • 1
gws
  • 459
  • 1
  • 7
  • 16
  • I found a [the?] solution to my problem while editing the question but decided to post anyway in hopes it will be useful since I didn't find an existing question about this exact scenario. – gws Jul 22 '15 at 16:01

1 Answers1

0

The deletion occurred in 'master' and has not been merged up to feature branches that already existed at that time. Thus the git-rm in 'master' is ahead of the commits in, say, 'de8060' and needs to be reapplied when checking out master.

Solution

Merge 'master' into every branch it is not already an ancestor of, before re-creating ".p4client". Then git will not need to 'update' the working copy with a 'newer' delete operation each time 'master' is checked out.

gws
  • 459
  • 1
  • 7
  • 16
  • Would rebasing the feature branch with master also work? – k0pernikus Jul 22 '15 at 16:00
  • @k0pernikus since that would put the branch commits 'ahead' of the commit that deleted .p4client, I would expect it to work. And if the file has already been re-created in master, it ought to survive the process, whereas merging definitely deleted it yet again. You should post this as an answer : ) – gws Jul 22 '15 at 16:29