我的本地 git 跟踪分支无法正常工作。我需要有关如何设置的建议
因此,我正在与另一位开发人员合作,想要拉取并推送到远程分支(顺便说一下,这不是远程主分支),但我想进行设置,以便当我检查计算机上的本地分支时,它会从远程分支拉取和推送到远程分支,而无需显式指定。
我在我的机器上运行了这个命令(假设远程分支称为 development,我创建的本地分支称为 dev1):
git branch --track dev1 origin/development
然后检查我的本地分支 >dev1,更改了一个文件,暂存它,提交它,然后尝试像这样推送:
git push origin
但后来我收到了这条消息:
Everything up-to-date
在创建 dev1 并检查后不久,我注意到我的 .git/config 文件中有多余的行出来:
[branch "dev1"]
remote = origin
merge = refs/heads/development
所以问题是我错过了什么? 基本上,我希望进行这样的设置,以便每次签出 dev1 并运行时:
git pull origin
它会自动从原始/开发中提取,而无需显式指定它,并且当我运行时:
git push origin
它会自动推送到原始/开发而无需指定明确这一点。
另外,当有明显的更改需要推送时,为什么它告诉我“一切都是最新的”。
So I'm working with another developer and want to pull and push to a remote branch (that is not the remote master by the way) but I want to set up so that when I check out my local branch on my machine it'll pull from and push to the remote branch without having to specify it explicitly.
I ran this command on my machine (suppose that the remote branch is called development and that the local branch I create is called dev1):
git branch --track dev1 origin/development
Then checked out my local branch dev1, changed a file, staged it, commited it and then tried to push like so:
git push origin
But then I got this message:
Everything up-to-date
Also I noticed extra lines in my .git/config file shortly after I created dev1 and checked it out:
[branch "dev1"]
remote = origin
merge = refs/heads/development
So the question is what am I missing?
Basically, I wish to set this up so that I every time I have checked out dev1 and run:
git pull origin
it automatically pulls from origin/development without having to specify this explicitly and when I run:
git push origin
it automatically pushes to origin/development without having to specify this explicitly.
Also, why did it tell me 'Everything up-to-date' when there were clearly changes to push.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如“Git推送不会做任何事情(一切都在- 至今)", < code>git push 仅推送已配置为推送到特定远程分支的本地分支。
由于push.default 设置:
由于您的本地分支与上游分支的名称不同,因此这就是您的问题。
将
push.default
设置为跟踪,它将起作用。然后,
git remote show origin
将列出配置为推送到 origin 的分支,然后应列出 dev1。As mentioned in "Git push won't do anything (Everything up-to-date)",
git push
only pushes local branches which have been configured to push to a particular remote branch.You
dev1
branch know what to pull, not where to push, because of the push.default setting:Since your local branch hasn't the same name than your upstream branch, here is your problem.
Set
push.default
to tracking and it will work.git remote show origin
will then list the branches configured to be pushed to origin, and dev1 should be listed then.