English 中文(简体)
与过去发生的情况一样,对it的重新抬头也出现了变化。
原标题:merge changes to git repo as if they had happened in the past
  • 时间:2012-04-11 11:34:10
  •  标签:
  • git

如果显而易见(或不可能的话),我会 new新。

我正在使用该系统网站。 我经常遇到这样的情况,即我对第三人部分做了修改,然后更新。

我怎么能像在我改变之前所做的那样,补充更新内容的改动? 或者这一重写历史吗?

我是否从引入该构成部分的旧承诺中设立了一个分支,加上更新的法典,然后并入主? 次级模块? 或者,我 bar开错误的树子,这种情况最好以另一种方式处理?

最佳回答

(最初,这一答案假定第3个政党部分来自公共邮袋,@jacob-dorman澄清说,他通过从大型项目的头版复制部分代码获得更新)

您需要保留一个存放处2分行:

  • master : every time you get a new snapshot of the component, commit it to this branch
  • tweaks : a branch based off the master branch, which contains the commits that constitute your custom tweaks

每次更新主编时,都要更新内容的新缩略,在<条码>上重新建立<条码>tweaks。 分支:

$ git rebase master tweaks

这将使你们的帽子实际上成为

因此,从一开始,这是它想看指挥线的。

Grab the first snapshot & store it on the master branch

mkdir my-fork-of-shinything
cd my-fork-of-shinything
git init
cp -R /tmp/shinything-snapshot-1 .  # copy the snapshot of code into your repo
git add -A    // stages ALL directory contents for commit
git commit -m "V1 snapshot of the shinything component"

这设立了你的主司。

Add your tweaks on a new tweaks branch

git checkout -b tweaks   // creates your new branch
... make your tweaks, commit them

后来,对原来的构成部分做了一些有意义的更新......

Grab a new component snapshot, update master & tweaks branches

git checkout master
rm -Rf * // delete the contents of the old snapshot
cp -R /tmp/shinything-snapshot-2 . // get the brand new snapshot in place
git add -A
git commit -m "V2 snapshot of shinything, brings fix for #234"

Your master branch now has an updated history of the component, with a commit for each snapshot update. Finally rebase the tweaks branch on to the master branch - each of the commits on your tweaks branch will be replayed, one after the other, on top of the new tip of the master branch:

git rebase master tweaks // re-bases the commits from your tweaks branch

More tweaks?

如果你需要增加更多的拖拉机,就应检查分行并添加:

git checkout tweaks
... make your tweaks, commit them
问题回答

页: 1

Br, Tim





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...