在开始工作之前忘了在GitHub上做一个分支 [英] forgot to do a fork on GitHub before starting my work

查看:117
本文介绍了在开始工作之前忘了在GitHub上做一个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我将公司C从github克隆到我的本地机器上的Project X的repo。我在本地为自己创建了一个分支,在它上面做了一些工作并在本地进行了提交。



现在我想向公司C发出一个请求,但我意识到我应该在gitub上创建一个分支来创建我自己的Project X的repo,并克隆它而不是C的repo。



如何在不克隆的情况下从此恢复我的本地叉,并通过手动复制文件重新开始?我想用git的魔法来拯救我自己。

解决方案

如果你想跟随你的项目开发按照惯例克隆,除了您的 origin 远程外,我们还添加了一个上游远程。所以你必须:
$ b


  1. 在github上分发项目

  2. 重命名当前的 origin remote(跟踪上游项目)用一个新名称 upstream : git remote rename origin upstream code>

  3. 添加个人github forked项目作为 origin remote: git remote add origin <您的个人github fork的网址>



  4. 这个想法背后的命名约定是 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:

    1. Fork the project on github
    2. Rename the current origin remote (that track the upstream project) with a new name upstream : git remote rename origin upstream
    3. Add you personal github forked project as the origin remote: git remote add origin <URL of your personal github fork>

    The idea behind that is to follow the naming conventions of origin for you personal repository and upstream for the project repository...

    这篇关于在开始工作之前忘了在GitHub上做一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆