How do I setup git to push and pull from the current branch?
So I have two tracked branches in my repo, 'testing' and 'master'. These are tracking to the same named branches on my remote server. I have the .gitconfig option for push.default set to 'tracking'. However when I do "git push origin" it merges my new changes with the Master branch ont he remote server. Here is the output of 'git remote show origin':
* remote origin
Fetch URL: git+ssh://******************
Push URL: git+ssh://******************
HEAD branch: master
Remote branches:
master tracked
testing tracked
Local refs configured for 'git push':
master开发者_C百科 pushes to master (up to date)
testing pushes to testing (fast-forwardable)`
Basically, I want to be able to just type 'git push' and 'git pull' and it will automatically push and pull to origin with the appropriate branch.
EDIT:
[*****]$ git config push.default
tracking
[*****]$ git --version
git version 1.7.3.4
You can change this behavior by editing the "push.default" property.
I always use the "simple" mode which tries to find a remote branch having the same name as your current branch and push to it.
git config --global push.default simple
This is the mode advised for beginners due to his ease of use and safety.
...refuse to push if the upstream branch’s name is different from the local one.
Find more in the official doc (end of the page): http://git-scm.com/docs/git-config
git config remote.origin.push HEAD
See the documentation for git push
(this was in towards the bottom in the examples section).
精彩评论