简体   繁体   English

GIT:更新到特定版本

[英]GIT: update to specific revision

I checked out a project copy 8 months ago, made lots of changes there. 我在8个月前检查了一个项目副本,在那里做了很多改动。 Now, I'd like to take all the new changes for the last 8 months. 现在,我想采取过去8个月的所有新变化。 The amount of changes is overwhelming (tens of thousands of commits). 变化的数量是压倒性的(成千上万的提交)。 What I'd like to do is to take changes of 1 month at a time, merge with my version, test. 我想做的是一次更改1个月,与我的版本合并,测试。 If I pull latest the amount of changes/conflicts is overwhelming. 如果我拉最新的变化/冲突的数量是压倒性的。

So... I guess it's clear what I'm trying to do, but I have no clue how to do it with GIT (I'm more familiar with svn). 所以......我想我很清楚我正在尝试做什么,但我不知道如何用GIT做这件事(我对svn比较熟悉)。 I use TortoiseGit on windows. 我在Windows上使用TortoiseGit。 All my local changes I committed to local branch, what do i need to do to pull changes made since I checked out, but not all of them? 我在本地分支机构所做的所有本地更改,我需要做些什么才能完成自签出后所做的更改,但不是全部更改?

thanks 谢谢

A pull is just a combination of a fetch plus a merge . pull只是一个fetch和一个merge的组合。 So do a fetch to get all the remote changes down to your local repo, then git log master..origin/master to get a list of all the commits made on origin since your branch diverged, then pick any SHA1 about a month up and git merge SHA1 to pull it into your master branch. 所以进行一次fetch以将所有远程更改下载到本地repo,然后git log master..origin/master以获取自分支发生以来对origin进行的所有提交的列表,然后选择任何SHA1大约一个月, git merge SHA1将其拉入您的master分支。 Lather, rinse, repeat. 泡沫,冲洗,重复。

If there are fewer changes on your side, it might be easier to do a git checkout -b upstream origin/master , git log upstream..master , and merge your changes over a month at a time. 如果您的更改较少,则可能更容易执行git checkout -b upstream origin/mastergit log upstream..master ,并一次合并您的更改一个月。

I don't know if splitting it up is going to end up being less work in the long run, though. 不过,我不知道将它拆分是否最终会减少工作量。 If you merge it all in one chunk, you're not really merging 10,000 commits, you're merging the tips of the branches, which means all those commits essentially get squashed into one big one. 如果你将它们合并在一个块中,那么你并没有真正合并10,000个提交,你正在合并分支的提示 ,这意味着所有这些提交基本上被压缩成一个大块。

You can always just merge up a couple commits at a time. 你总是可以一次只合并几个提交。 Just look back and say month 1 is 345bbdkj...., git merge 345bbdkj (just enough of the hash to identify the commit). 回顾一下,说第1个月是345bbdkj ...., git merge 345bbdkj (只需要足够的哈希来识别提交)。 You can keep on doing that until you get a conflict. 你可以继续这样做,直到你遇到冲突。

Additionally, you can rebase your repo so your changes are made on top of all these other changes instead of the other way around. 此外,您可以重新设置您的仓库,以便在所有其他更改之上进行更改,而不是相反。 Your changes will become a mess no matter what you do here I think though :( 10k+ commits is a lot to deal with. 无论你在这里做什么,你的改变都会变得一团糟但我认为:( 10k +提交需要处理很多事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM