我正在尝试创建一个名为springdevelopment的分支,并将代码推送到git。
git checkout -b springdevelopment
git add .
git commit -m 'initial commit'
git push origin springdevelopment
git checkout --track origin/springdevelopment
当我执行git remote show origin时。我错过了当地分支机构git pull section的“spring development”。
你能否解释一下发生了什么以及我做错了什么。
提前感谢您提供有价值的信息。
答案 0 :(得分:8)
git checkout -b springdevelopment
git add .
git commit -m 'initial commit'
git push -u origin springdevelopment
无需这样做:
git checkout --track origin/springdevelopment
您随时可以使用以下方式更新跟踪:
git branch --set-upstream-to origin/springdevelopment
将您的refspec更新为:
[remote "origin"]
url = git@github.com:user/project.git
fetch = refs/heads/*:refs/remotes/origin/*
答案 1 :(得分:0)
虽然我认为可以选择推送更新跟踪引用(refs/remote/...
),但我现在无法在文档中看到它的任何痕迹。只需致电
git fetch
推送更新后。
答案 2 :(得分:0)
我的git pull
没有拉出正确的遥控器。我意识到我添加了第二个上游github
并超过了我的“主”分支。
所以我修改了.git/config
文件:
[branch "master"]
remote = github
merge = refs/heads/master
为:
[branch "master"]
remote = origin
merge = refs/heads/master