我正在使用三个分叉版本的源代码。仅供参考我将名称更改为不透露身份/回购。以下是它的布局:
MyMBP:~/Documents/_library$ git remote -v
abc https://github.com/abc/_library (fetch)
abc https://github.com/abc/_library (push)
origin https://github.com/123/_library.git (fetch)
origin https://github.com/123/_library.git (push)
upstream https://github.com/source/_library (fetch)
upstream https://github.com/source/_library (push)
这里,上游是最新和稳定版本的原始源代码。 Origin是我的分叉版本。 ABC是别人的版本。
ABC有一个分支机构,我从那里开始工作。我想然后进行更改并推送到我的仓库(原产地),然后提交拉动请求。 ABC的分支被称为“abc / obs-noise”。
根据git状态:
git status
HEAD detached from abc/obs-noise
当我对所述文件进行更改时,我承诺:
git commit
[detached HEAD e8eeea3] OBSERVATION NOISE ADDITION TO THE MONITORS
1 file changed, 23 insertions(+), 11 deletions(-)
然后我git推(据说是我的起源)。
git push -u origin abc/obs-noise
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 733 bytes | 733.00 KiB/s, done.
Total 5 (delta 4), reused 1 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/123/_library.git
* [new branch] abc/obs-noise -> abc/obs-noise
但是,我去了我的回购...没有abc / obs-noise,或者这个提交的任何证据。我是git的菜鸟,但我几乎可以肯定我做的一切都是正确的,它看起来就是那样。我想知道我在哪里找到我的提交?我不想重做我所有的工作。
首先,你坐在一个独立的HEAD上。这意味着您刚刚进行的任何提交都不会移动原始分支指针。如果更改活动分支,那么你很有可能丢失这些提交,这就是为什么git push不会推送任何新内容:原始分支指针尚未被移动。
首先,当您开始处理任何远程分支时,您应该创建一个对应于给定远程分支的本地分支。使用
git checkout -b <local_branch_name> <remote>/<branch>
然后当你提交时,这个<local_branch_name>
将提前跟随你的提交行。当您需要将给定的提交行推送到远程分支时,请使用
git push <remote> <local_branch_name>:<remote_branch_name>
如果需要为不同的远程控制器创建多个开发线,则应创建多个相应的本地分支并单独推送它们。