tags:

views:

108

answers:

2

I want to delete a file in a project, and I want that file to be deleted for everyone else also working on the project when they pull.

When we start, all co-workers have a file "testfile" in their tree and are on the same branch.

If I remove the file with:

% git rm testfile
% git commit -a
% git push

Then my co-worker pulls this commit:

% git pull
% ls testfile
testfile

Why is this file still here and what can I do to get rid of it. Die!

+8  A: 

I have to say 'it works for me'. I think you need to post more details about your setup, exact usage and any output or error messages that you are getting because it should work.

$ git --git-dir=common.git init --bare
Initialized empty Git repository in /rmtest/common.git/

$ git clone common.git a
Initialized empty Git repository in /rmtest/a/.git/
warning: You appear to have cloned an empty repository.

$ git clone common.git b
Initialized empty Git repository in /rmtest/b/.git/
warning: You appear to have cloned an empty repository.

$ cd a
$ touch testfile
$ git add testfile
$ git commit -m initial
[master (root-commit) be09b47] initial
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 testfile

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 213 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /rmtest/common.git
 * [new branch]      master -> master

$ cd ../b
$ git pull
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /rmtest/common
 * [new branch]      master     -> origin/master

$ git rm testfile
rm 'testfile'

$ git commit -m "removed testfile"
[master 53b13de] removed testfile
 0 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 testfile

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (2/2), 202 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /rmtest/common.git
   be09b47..53b13de  master -> master

$ cd ../a
$ git pull
remote: Counting objects: 3, done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From /rmtest/common
   be09b47..53b13de  master     -> origin/master
Updating be09b47..53b13de
Fast forward
 0 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 testfile

$ ls
.git/
Charles Bailey
+1 for actually testing this.
Ionuț G. Stan
Did you know you dont have to actually write +1, there is a little arrow thing where you can vote the post up or down. *grin*
Jacob
@Jacob: don't know about you, but I see it like a feedback, and I like to know the reasons for upvoting
alexandrul
+2  A: 

I had the same behavior when working on a wrong branch. Be sure you push to the same branch your co-worker pull from. Try "git branch -a" to show local and remote branches and eventually delete wrong (remote or local) branches (git branch -r -d for deleting a remote branch).

If nothing helps and you cannot find a solution, clone a new repository from your (or your co-workers) working repository and test it again.

devarni