1

I have two local copies of the a project on two different computers (and a remote origin on github)

I just realized I accidentally committed the .project file, which of course, must be different on each machine.

  • on computer A, I have computer As .project file
  • on computer B, I have computer Bs .project file.
  • in github, I think i have computer As .project file.

Computer A has done an update, committed and pushed. Now I want to pull the changes to B, but it wont let me because the local .project file is not committed.

What can I do? If I use tortoise gits "delete (keep local)" feature on computer B, then commit, presumably it will delete .project from the master repo on github, then next time I pull on computer A, I will lose my local .project file and it will break.

any ideas?

user229044
  • 232,980
  • 40
  • 330
  • 338
John Little
  • 10,707
  • 19
  • 86
  • 158
  • possible duplicate of [Remove a file from a Git repository without deleting it from the local filesystem](http://stackoverflow.com/questions/1143796/remove-a-file-from-a-git-repository-without-deleting-it-from-the-local-filesyste) – Ja͢ck Jun 30 '15 at 10:34

2 Answers2

1

First, in computer A, record the deletion of the .project and push:

git rm --cached .project   # preserve the file on the disk 
                           # while removing it from the index
git add -u .project
git commit -m "Remove .project"
git push

Then, in Computer B, you can pull: the .project shouldn't be impacted.


Note that the .project can be versioned because it doesn't have to be different.
See for instance ".classpath and .project - check into version control or not?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Create a .gitignore file, put all the file names which you want to ignore into the .gitignore and then commit it.

Oldskool
  • 34,211
  • 7
  • 53
  • 66
Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73