I'm trying to learn git by playing around with it using SourceTree as as tool.
I added my local repository to a BitBucket repository and then made a couple of changes locally. I committed them, and then pushed them. I then logged onto BitBucket and manually changed a portion of the document (item "Added 4"). Then I went back to my local copy and changed it again and committed it. When I tried to push it, it told me I first had to pull and merge. So I did.
Then I pushed again. It worked.
Now, the master (the top one. Why are there two?) carries a caption saying 2 ahead
. What does this mean exactly? What is it ahead of?
UPDATE
git status gives me:
JustMe@IMRAY ~/Projects/BlaBlaUser/gitPractice (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
branch is X commits behind means that there are X new (unmerged) commits on the branch which is being tracked by your current branch. branch is X commits ahead analogously means that your branch has X new commits, which haven't been merged into the tracked branch yet.
A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet.
Basically, you need to push
to your remote branch again to get rid of the 2 ahead
so to speak.
The master (the one on the top) is your local tracking branch, and origin/master
is a remote tracking branch that records the status of the remote repository from your last push
, pull
, or fetch
. origin
refers to your remote repository and master
is the current branch (also default) for that repository.
So in essence, it says that your branch (master
) is ahead of the remote master branch (origin/master
) by two commits, and that is why I say that you need to push
again.
When you do a git status
on your local, it should give you more clue about what is to be done.
It means that you have local commits that have not yet been pushed to that remote.
For example:
* (master) Fix bar
* Fix foo
* (origin/master) Add bar
* Add foo
(newer commits are at the top)
Here you see that origin/master
is two commits behind master
.
You may use git push origin master
to push your master
branch to origin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With