MrBr
MrBr

Reputation: 1916

git push says Everything up to date

I am having trouble understanding the concept of git local and remote versioning. For example I have a iPhone app in a local git rep. Initally this was my master branch. I then checked out a new branch git checkout -b "update-2.0.1".

Then I set git push origin update-2.0.1 to ensure that I have a seperate branch for developing this app update and when done merge it back into my master branch. Fine!

Now that I am on my update-branch I want to create branches for every issue ID. So I say git checkout -b "#3178" - when I now try to push this new issue-branch in my remote repository git says "Everything-up-to-date".

I don't see why it is not possible to push this issue branch to the remote repository?

git remote -b returns

origin/master

origin/update-2.0.1

I would love to see a third branch

origin/update-2.0.1/#3178

Upvotes: 2

Views: 7967

Answers (3)

MrBr
MrBr

Reputation: 1916

The reason the new branch was not pushed into the remote repository was simply because I did not use the double quotes.

git push origin "new-branch"

Also when renaming branches always use the double quotes - at least in my case it worked while not all code samples in the web use this syntax.

Upvotes: 0

Matt Gibson
Matt Gibson

Reputation: 14949

You need to repeat the first command:

git push origin <name-of-branch>

to create the corresponding remote branch for every new branch you create locally. Git won't push unless it has somewhere to push to. This can be an empty branch if that's what you need.

You would then end up with

origin/<name-of-branch>

and not

origin/<name-of-branch>/<name-of-other-branch>

Although they will be listed without a hierarchy, they do in fact branch off each other. Use gitk or something to view the history log visually to confirm this.

If you want to finish working on the issue and merge it into the branch it started from, do this:

git checkout <name-of-original-branch> // update-2.0.1
git merge --no-ff <name-of-finished-branch> // #3178
git push origin // Will write local update-2.0.1 to origin

Check out git flow if you want a nice visual explanation of why using the --no-ff option is a very powerful model for tracking branches that come off other branches as part of your release cycle.

Upvotes: 2

Ren&#233; H&#246;hle
Ren&#233; H&#246;hle

Reputation: 27295

Switch to the branch you want to merge for example go to "master" and merge your other branch update-2.0.1 to the master.

git checkout master
git merge update-2.0.1
git push

for example. Then you have all changes from the update branch in the master branch and you can push this.

When you really need only a new branch then make only

git branch name

from the branch you are at this time. When you push it to origin you have a new remote branch

check it with

git branch -r #remote branches
git branch #local branches

Upvotes: 0

Related Questions