I have a repository on github.com that I git pull down to my workstation, edit, commit then git push the changes back to github. This all works fine.
But I often clone read-only copies from github.com using e.g.:
git clone git://github.com/jhsrennie/Test.git Test-ro
Typically this is because I have temporary test installations that I won't be developing on, but I need to check the code builds and runs. The copy of my github repository can be read-only because no changes will ever need pushing back to github. The trouble is that when I pull down changes from github to my read-only copy using:
git pull origin master
I now find that git status shows something like:
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
I can't push the changes back, and I wouldn't want to anyway, but the outstanding commits cause me problems e.g. I can't check out new remote branches. I end up having to delete my read-only repository and re-clone it every time I need to update it.
How can I update my read-only copies of my github repository from github.com without causing them to think there are commits I need to push?
Alternatively, am I doing this in a silly way and is there a better way to achieve my goal?
Response to Cupcake's answer
It seems strange to me as well, and there's clearly something I'm missing. This is how to reproduce the problem:
- Clone the repository with:
git clone git@github.com:jhsrennie/Test.git Test-rw
- Clone the readonly copy with:
git clone git://github.com/jhsrennie/Test.git Test-ro
- Make changes to
Test-rw
, thengit add
andgit commit
git status
now shows (as you'd expect):
renniej@RATHAUS /d/Dev/GIT/Test-rw (master)
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
And finally I push the change up to github with git push origin master
Now switch to the read-only copy and check that git status
shows:
renniej@RATHAUS /d/Dev/GIT/Test-ro (master)
$ git status
# On branch master
nothing to commit, working directory clean
Update it using git pull origin master
and I get (this was a change to the single file README.md):
renniej@RATHAUS /d/Dev/GIT/Test-ro (master)
$ git pull origin master
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (3/3), done.
From git://github.com/jhsrennie/Test
* branch master -> FETCH_HEAD
Updating 76b02d1..5b03266
Fast-forward
README.md | 2 ++
1 file changed, 2 insertions(+)
and git status
now gives:
renniej@RATHAUS /d/Dev/GIT/Test-ro (master)
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
The only explanation I can think of is that the read-only copy doesn't recognise that the updates have come from the same repository that it was originally cloned from, but this seems strange to say the least.