[英]git remote tracking branch pushes new branch
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. 我使用SourceTree GUI工具在本地创建了一个名为CP_Server_Release的远程跟踪分支。 This branch is set up to track the remote branch origin/ICN_Portal_Server_Release.
设置此分支以跟踪远程分支源/ 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. 我对CP_Server_Release进行了更改并提交。
I then pushed my changes but I ended up creating a new branch called CP_Server_Release in the remote repo! 然后,我推送了更改,但最终在远程存储库中创建了一个名为CP_Server_Release的新分支! This is not what I was expecting which was to push my changes into the ICN_Portal_Server_Release.
这不是我期望将更改推送到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.
我领先于一次提交,因为上次我推送了一个新分支,而不是将更改推送到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. 因此,现在我要继续并将更改推送到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).
我唯一能想到的是,它可能与我有关,而不是在存储库的根目录(/ icnportal_server)中,而不是在子目录(src / main / java)中。 If so, why is that?
如果是这样,那为什么呢?
Thanks for the help! 谢谢您的帮助!
try next configuration (works for my 1.8.3.2 git version) 尝试下一个配置(适用于我的1.8.3.2 git版本)
$ git config --global push.default upstream
$ git push
When you use git branch
you're creating a new branch but not positioning on it. 当您使用
git branch
您正在创建一个新分支,但没有在其上定位。 So after that you have to do git checkout yourNewBranch
. 因此,在那之后,您必须执行
git checkout yourNewBranch
。
Instead of this, you can use git checkout -b yourNewBranch
to create a new branch and position on it. 取而代之的是,您可以使用
git checkout -b yourNewBranch
来创建新分支并在其上定位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.