I'm having trouble understanding what I did wrong when pushing to a remote branch. Here is what I did:
I created a remote tracking branch locally named CP_Server_Release using the SourceTree GUI tool. This branch is set up to track the remote branch origin/ICN_Portal_Server_Release. I wanted a slightly shorter name for my local branch for convenience.
I made changes on CP_Server_Release and committed.
I then pushed my changes but I ended up creating a new branch called CP_Server_Release in the remote repo! This is not what I was expecting which was to push my changes into the ICN_Portal_Server_Release. So I figured something was wrong with the tracking set up.
I then deleted the new remote branch I created unintentionally and I ensured I was tracking the branch I want to by running the following:
moliveira-> git branch -u origin/ICN_Portal_Server_Release
Branch CP_Server_Release set up to track remote branch ICN_Portal_Server_Release from origin.
[~/src_git/icnportal_server/src/main/java]
moliveira-> git status
# On branch CP_Server_Release
# Your branch is ahead of 'origin/ICN_Portal_Server_Release' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
That looks right to me. I am ahead by one commit because last time I pushed a new branch instead of pushing my changes into origin/ICN_Portal_Server_Release. It also looks like I am tracking the correct remote branch.
So now I want to go ahead and push my changes to origin/ICN_Portal_Server_Release.
[~/src_git/icnportal_server/src/main/java]
moliveira-> git push
Counting objects: 109, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (30/30), 5.05 KiB | 0 bytes/s, done.
Total 30 (delta 10), reused 0 (delta 0)
To http://pdevicnos101.corp.intuit.net:81/git/cns/icnportal_server.git
* [new branch] CP_Server_Release -> CP_Server_Release
It created a new branch again!! I don't understand why. What am I doing wrong? The only thing I can think of is it may have something to do with me not being in the root directory of the repo (/icnportal_server) but instead in a subdirectory (src/main/java). If so, why is that?
Thanks for the help!
try next configuration (works for my 1.8.3.2 git version)
$ git config --global push.default upstream
$ git push