I am trying to understand how git works. So I initialized an empty repo and added a file to it as following.
cd /home/adnan/workspace
mkdir git-test
cd git-test
git init
touch README
git add .
git commit -m "initial commit"
Now I cloned it this repo using the following sequence of commands
cd /home/adnan/Desktop
git clone /home/adnan/workspace/git-test
after that I made changes to README file, committed them and pushed them to the first repo using following commands
cd /home/adnan/Desktop/git-test
vi README
git commit -a -m "second commit"
git push
Now running git log in both repos shows same thing i.e
commit
cdf192f7e26e734c7a56cc830ade2e2d13c6fb0d
Author: Adnan Waheed
Date:
Tue Mar 1 14:05:12 2011 +0500second commitcommit
f8b75838e728e46cae949f66ff86d29c0864d976
Author: Adnan Waheed
Date:
Tue Mar 1 14:03:23 2011 +0500initial commit
but I cant figureout how to get the changes in the original repo i.e /home/adnan/workspace/git-test. If I try to do git checkout, I get this message:
M README
How do I get the changes that I made in the cloned repo and pushed?
Did you see an error message when you did
git push? Something like this (assuming git >1.7.0)?Basically by default you can’t push to a non-bare repository. But what you can do is a
git pull, so try:and you should see something like: