在开始工作之前忘了在GitHub上做一个分支 [英] forgot to do a fork on GitHub before starting my work
问题描述
现在我想向公司C发出一个请求,但我意识到我应该在gitub上创建一个分支来创建我自己的Project X的repo,并克隆它而不是C的repo。
如何在不克隆的情况下从此恢复我的本地叉,并通过手动复制文件重新开始?我想用git的魔法来拯救我自己。
如果你想跟随你的项目开发按照惯例克隆,除了您的 origin
远程外,我们还添加了一个上游
远程。所以你必须:
$ b
- 在github上分发项目
- 重命名当前的
origin
remote(跟踪上游项目)用一个新名称upstream :
git remote rename origin upstream code>
- 添加个人github forked项目作为
origin remote:
git remote add origin <您的个人github fork的网址>
- Fork the project on github
- Rename the current
origin
remote (that track the upstream project) with a new nameupstream
:git remote rename origin upstream
- Add you personal github forked project as the
origin
remote:git remote add origin <URL of your personal github fork>
这个想法背后的命名约定是 origin
为您的个人存储库和上游
为项目存储库...
Suppose I clone Company C's repo of Project X from github to my local machine. I create a branch for myself locally, do some work on it and make commits to my branch locally.
Now I want to make a pull request to Company C, but I realize that I should have done a fork on gitub to create my own repo of Project X and cloned that instead of Company C's repo.
How do I recover from this without cloning my fork locally and starting over by copying files manually? I'd like to use git's magic to save myself.
If you want to follow the development of the project you've cloned, by convention, we add a upstream
remote in addition to your origin
remote. So you have to:
The idea behind that is to follow the naming conventions of origin
for you personal repository and upstream
for the project repository...
这篇关于在开始工作之前忘了在GitHub上做一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!