Domanda

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?

Git - SourceTree screenshot

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
È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top