Reputation: 301
I checked out a new branch from our repo. Everything is working fine for our develop branch. But on the new branch 'push' isn't doing anything.
Everything looks normal - there are 2 commits to push.
-> git branch -vv
develop 8ab7ef1 [origin/develop] Merge branch 'develop' of git.example.com:core-platform into develop
* hotfix112 8521cef [origin/hotfix/1.1.2: ahead 2] CORE-1263 - Completed merging from dev into hot fix.
But Push doesn't do anything:
-> git push
Everything up-to-date
-> git status
# On branch hotfix112
# Your branch is ahead of 'origin/hotfix/1.1.2' by 2 commits.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
I found that 'git pull' uses remote, but 'git push' doesn't:
-> git remote show origin
* remote origin
Fetch URL: [email protected]:core-platform.git
Push URL: [email protected]:core-platform.git
HEAD branch: develop
Remote branches:
core-platform-1.0.0 tracked
develop tracked
hotfix/1.1.2 tracked
master tracked
release/1.0.0 tracked
release/1.1.1 tracked
Local branches configured for 'git pull':
develop merges with remote develop
hotfix112 merges with remote hotfix/1.1.2
Local ref configured for 'git push':
develop pushes to develop (up to date)
->
I cannot figure out why hotfix112 is not linked to the remote, but the pull is.
How do I fix this configuration?
Upvotes: 4
Views: 3292
Reputation: 3737
Git acts as you've described because you have the following situation:
As usually the case with git, you have a few alternatives how to set up git to act as desired:
1.) The easiest would be to change the name of your local branch to match the name of the remote branch. Afterwards, push starts working automatically. So just rename branch 'hotfix112' to 'hotfix/1.1.2':
git branch -m hotfix112 hotfix/1.1.2
2.) You can change the push behaviour via setting option push.default to 'tracking'. Because you already have branch 'hotfix112' set to track origin/hotfix/1.1.2, git push will work as desired. To set the local git option run:
git config --local push.default tracking
3.) You can manually edit your .git/config file and set push to match local refspec 'hotfix112' to remote 'hotfix/1.1.2'. You should add the push line below your [remote "origin"] section:
[remote "origin"]
url = ...
fetch = ...
push = hotfix112:hotfix/1.1.2
First and third approach work only on the hotfix112 branch. The second works for all tracking branches in that repository (or globally if global option was used).
Upvotes: 2
Reputation: 1256
The current behavior of git push
(without any additional parameters) is to push all branches having the same name in the local and remote repository. Since your local branch name differs from your remote branch name, if you change them to match, git push
should push your changes. Be advised though that this behavior will be changing in a future version of git (probably 2.0). See: http://article.gmane.org/gmane.comp.version-control.git/193308. If you would like to change the behavior of git push
right now, type git help config
and search for "push.default".
Upvotes: 0
Reputation: 1594
Try git push origin/hotfix/1.1.2 (the remote branch) hotfix112 (the local branch), possibly afer doing a push to the remote it will create a link. Weird though that is did not when you branched.
Upvotes: 0