I\'m a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-yo
sometimes there's a difference between the local cached version of origin master (origin/master) and the true origin master.
If you run git remote update
this will resynch origin master with origin/master
see the accepted answer to this question
Differences between git pull origin master & git pull origin/master
I had the problem "Your branch is ahead of 'origin/master' by nn commits." when i pushed to a remote repository with:
git push ssh://git@xxx.repositryhosting.com/yyy/zzz.git
When i found that my remote adress was in the file .git/FETCH_HEAD and used:
git push
the problem disappeared.
It's waiting for you to "push". Try:
$ git push
It is possible to reset to a specific commit before your own commits take place.
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)
Use git log
to find what commit was the commit you had before the local changes took place.
$ git log
commit 3368e1c5b8a47135a34169c885e8dd5ba01af5bb
...
commit baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e
...
Take note of the local commits and reset directly to the previous commit:
git reset --hard baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e
I thought my laptop was the origin…
That’s kind of nonsensical: origin
refers to the default remote repository – the one you usually fetch/pull other people’s changes from.
How can I:
git remote -v
will show you what origin
is; origin/master
is your “bookmark” for the last known state of the master
branch of the origin
repository, and your own master
is a tracking branch for origin/master
. This is all as it should be.
You don’t. At least it makes no sense for a repository to be the default remote repository for itself.
It isn’t. It’s merely telling you that you have made so-and-so many commits locally which aren’t in the remote repository (according to the last known state of that repository).
I am struggling with this problem and none of the previous answers tackle the question as I see it. I have stripped the problem back down to its basics to see if I can make my problem clear.
I create a new repository (rep1), put one file in it and commit it.
mkdir rep1
cd rep1
git init
echo "Line1" > README
git add README
git commit -m "Commit 1"
I create a clone of rep1 and call it rep2. I look inside rep2 and see the file is correct.
cd ~
git clone ~/rep1 rep2
cat ~/rep2/README
In rep1 I make a single change to the file and commit it. Then in rep1 I create a remote to point to rep2 and push the changes.
cd ~/rep1
<change file and commit>
git remote add rep2 ~/rep2
git push rep2 master
Now when I go into rep2 and do a 'git status' I get told I am ahead of origin.
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
README in rep2 is as it was originally, before the second commit. The only modifications I have done are to rep1 and all I wanted to do was push them out to rep2. What is it I am not grasping?