在github.com上分支的项目之上,我该如何重新播放本地git repo的提交? [英] How do I re-play my commits of a local git repo, on top of a project I forked on github.com?

查看:78
本文介绍了在github.com上分支的项目之上,我该如何重新播放本地git repo的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道我应该从一开始就分出这个项目,但这就是我现在的情况。 :)



我有一个本地git存储库,包含我的博客,在本地计算机上,有几个月的提交历史记录。本来我只是从这个回购下载文件:
http://github.com/ mojombo / mojombo.github.com ,并继续使用本地git回购,第一次提交看起来像mojombo回购的最新文件。



我会现在想分叉项目,让我的本地git repo提交在其上重播,所以看起来我从一开始就分叉项目,然后将它
推回到我的分支的mojombo回购版本中,在我的github账户上:



http: //github.com/program247365/mojombo.github.com



因此,历史记录可能如下所示:

  mobjombo回购:1 --- 2 --- 3 ---- 23 
\
我的博客回购承诺: --25 ---

我愿意知道什么git命令,我完全可以使用,做到这一点?



我已经看过这个问题。我需要添加mojombo的回购作为我的项目的一个远程,然后将其拉入,合并,解决冲突,然后推送到我在github上分叉的项目?

解决方案

当我尝试 git pull 时,它给了我以下错误:

  $ git pull grid master:master 
! [被拒绝] master - >主(非快进)

在我的特殊情况下,似乎 git rebase 是我要走的路,如以下步骤所示:

  #Clone my从github分叉的项目
git clone git@github.com:program247365 / mojombo.github.com.git

#将我的回购作为远程回购添加,其别名为'grid'
git remote add gridpath / to / remote / gitrep / with / all / history / unrelated / to / mojombo /

#Rebase my commits on mojombo's
git rebase master grid / master

#切换到本地主分支
git checkout master

#通过git打开我的mergetool,开始纠正出现在我的回购和mojombo的
git mergetool

#将我的基准/合并回购推回到Github.com
git push github


Yes, I know I should have just forked the project from the beginning, but this is what situation I'm in now. :)

I have a local git repository, that contains my blog, on my local computer, that has several months of commit history. Originally I simply downloaded the files from this repo: http://github.com/mojombo/mojombo.github.com and continued on with my local git repo, with the first commit looking like the latest files from mojombo's repo.

I would now like to fork the project, and have my local git repo commits be replayed on top of it, so it looks like I forked the project from the beginning, and then push it back to my forked verson of mojombo's repo, on my github account:

http://github.com/program247365/mojombo.github.com

So perhaps the history would then look like this:

mobjombo repo:     1---2---3----23
                                 \
my blog repo commits:             24---25---

I'd like to know what git commands, I can use exactly, to do this?

I've looked at this question. Will I have to add mojombo's repo as a remote to my project, and then pull it in, merge, resolve conflicts, and then push to my forked project on github?

解决方案

When I tried git pull it gave me the following error:

$ git pull grid master:master
! [rejected]        master     -> master  (non fast forward)

In my particular case, it seemed that git rebase was the way to go for me, as shown by the steps here:

#Clone my forked project from github
git clone git@github.com:program247365/mojombo.github.com.git 

#Add my repo as a remote repo, with the alias 'grid'
git remote add grid "path/to/remote/gitrep/with/all/history/unrelated/to/mojombo/" 

#Rebase my commits on top of mojombo's
git rebase master grid/master

#Switch to the local master branch 
git checkout master

#Call up my mergetool via git, to start rectifying the conflicts that emerge between my repo, and mojombo's
git mergetool

#Push my rebased/combined repo back to Github.com
git push github

这篇关于在github.com上分支的项目之上,我该如何重新播放本地git repo的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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