Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我是否在GitHub上正确设置了分叉遥控器?_Git_Github - Fatal编程技术网

我是否在GitHub上正确设置了分叉遥控器?

我是否在GitHub上正确设置了分叉遥控器?,git,github,Git,Github,我公司的回购协议不允许推送,所以过程是推送它,推送你的叉子,做一个公关 我的遥控器设置如下: $ git remote -v origin git@github.com:heriettaLux/company-repo.git (fetch) # my fork origin git@github.com:heriettaLux/company-repo.git (push) # my fork upstream git@github.com:company-repo.git (fetch

我公司的回购协议不允许推送,所以过程是推送它,推送你的叉子,做一个公关

我的遥控器设置如下:

$ git remote -v
origin git@github.com:heriettaLux/company-repo.git (fetch)  # my fork
origin git@github.com:heriettaLux/company-repo.git (push)   # my fork
upstream git@github.com:company-repo.git (fetch)
upstream git@github.com:company-repo.git (push)
有没有更好的方法来设置这个

我现在在
master
上,当我执行
git log
时,我看到:

$ git log
commit 21424... (HEAD -> master, upstream/master)
(Commit info)

commit 29128... (origin/master, origin/HEAD)
(Commit info)

我想开始一个新的功能分支,但我不知道这是否意味着我不同步?我只是想确保我有我公司最新的
master
,这样我就可以在它的基础上创建一个新的分支。我尝试了
git-pull-origin-master
git-pull-upstream-master
,但都说它是最新的,现在我完全搞糊涂了。

在创建新功能分支之前,我只需从公司存储库中获取:

git fetch upstream
git switch -c newBranch upstream/master
这样,我就可以从最新的上游
master
分支开始工作

然后我可以定期从上游获取,并在其上重新设置我的功能分支的基础,以确保我的工作仍然基于公司存储库中的最新版本。

从这里可以看到,设置看起来不错。不过,这种工作方式有点棘手,因为现在涉及到三个Git存储库:一个在笔记本电脑(或其他本地计算机)上,一个在GitHub上,您可以
Git push
,另一个在GitHub上,您只能从GitHub存储库向其发出“pull请求”。因此,现在您必须维护您的笔记本电脑副本和GItHub副本。您的笔记本电脑(或任何其他)正在使用提交
21424…
作为当前提交。这与
上游
调用
的提交相同。然而,与此同时,您的GitHub repo正在调用commit
29128…
master
。这表明,但由于我们看不到更多内容,并没有说,只表明您的GitHub副本需要一个
git推送
来更新。