git-rebase

How do I select a merge strategy for a git rebase?

梦想的初衷 提交于 2019-11-26 06:14:29
问题 git-rebase man page mentions -X<option> can be passed to git-merge . When/how exactly? I\'d like to rebase by applying patches with recursive strategy and theirs option (apply whatever sticks, rather than skipping entire conflicting commits). I don\'t want merge, I want to make history linear. I\'ve tried: git rebase -Xtheirs and git rebase -s \'recursive -Xtheirs\' but git rejects -X in both cases. git rebase -Xtheirs works in recent versions, except tree conflicts need to be resolved

git pull VS git fetch git rebase

孤人 提交于 2019-11-26 06:10:27
问题 Another question said git pull is like a git fetch + git merge . But what is the difference between git pull VS git fetch + git rebase ? 回答1: It should be pretty obvious from your question that you're actually just asking about the difference between git merge and git rebase . So let's suppose you're in the common case - you've done some work on your master branch, and you pull from origin's, which also has done some work. After the fetch, things look like this: - o - o - o - H - A - B - C

git rebase without changing commit timestamps

删除回忆录丶 提交于 2019-11-26 05:52:23
问题 Would it make sense to perform git rebase while preserving the commit timestamps? I believe a consequence would be that the new branch will not necessarily have commit dates chronologically. Is that theoretically possible at all? (e.g. using plumbing commands; just curious here) If it is theoretically possible, then is it possible in practice with rebase, not to change the timestamps? For example, assume I have the following tree: master <jun 2010> | : : : oldbranch <feb 1984> : / oldcommit

How do I run git rebase --interactive in non-interactive manner?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 05:25:05
问题 Is it possible to do following? Make git rebase --interactive to just output standard boilerplate to a file, instead to outputting to a file and opening it in editor. Let the user edit the file. Let user re-run git rebase with the name of edited file. Go on with the usual rebase process. Usecase: scripted rebasing of course. See how to re-order commits in Git non-interactively for example. 回答1: After some thinking and research, the answer turned out to be trivial: git rebase -i takes the

Squash the first two commits in Git? [duplicate]

梦想与她 提交于 2019-11-26 04:02:41
问题 This question already has an answer here: Combine the first two commits of a Git repository? 8 answers With git rebase --interactive <commit> you can squash any number of commits together into a single one. That\'s all great unless you want to squash commits into the initial commit. That seems impossible to do. Are there any ways to achieve it? Moderately related: In a related question, I managed to come up with a different approach to the need of squashing against the first commit, which is,

How to squash all git commits into one?

旧时模样 提交于 2019-11-26 03:21:53
问题 How do you squash your entire repository down to the first commit? I can rebase to the first commit, but that would leave me with 2 commits. Is there a way to reference the commit before the first one? 回答1: Perhaps the easiest way is to just create a new repository with current state of the working copy. If you want to keep all the commit messages you could first do git log > original.log and then edit that for your initial commit message in the new repository: rm -rf .git git init git add .

Git: How to rebase many branches (with the same base commit) at once?

你。 提交于 2019-11-26 03:09:54
问题 I have a master branch in my project, that I use to pull changes from other people. From that, I usually have several topic branches on which I\'m currently working. My question is: Is there a way for me to pull new changes into my master and then rebase ALL of my topic branches onto that at once? This is the situation: D--E topic1 / A--B--C master \\ F--G topic2 And I want to accomplish this with one single command (H came from upstream) : D\'--E\' topic1 / A--B--C--H master \\ F\'--G\'

Combine the first two commits of a Git repository?

走远了吗. 提交于 2019-11-26 01:48:19
问题 Suppose you have a history containing the three commits A, B and C : A-B-C I would like to combine the two commits A and B to one commit AB : AB-C I tried git rebase -i A which opens up my editor with the following contents: pick e97a17b B pick asd314f C I change this to squash e97a17b B pick asd314f C Then Git 1.6.0.4 says: Cannot \'squash\' without a previous commit Is there a way or is this just impossible? 回答1: Use git rebase -i --root as of Git version 1.7.12. In the interactive rebase

How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?

喜欢而已 提交于 2019-11-26 01:39:13
问题 We have all heard that one should never rebase published work, that it’s dangerous, etc. However, I have not seen any recipes posted for how to deal with the situation in case a rebase is published. Now, do note that this is only really feasible if the repository is only cloned by a known (and preferably small) group of people, so that whoever pushes the rebase or reset can notify everyone else that they will need to pay attention next time they fetch(!). One obvious solution that I have seen

How to cherry-pick multiple commits

為{幸葍}努か 提交于 2019-11-26 01:34:45
问题 I have two branches. Commit a is the head of one, while the other has b , c , d , e and f on top of a . I want to move c , d , e and f to first branch without commit b . Using cherry pick it is easy: checkout first branch cherry-pick one by one c to f and rebase second branch onto first. But is there any way to cherry-pick all c - f in one command? Here is a visual description of the scenario (thanks JJD): 回答1: Git 1.7.2 introduced the ability to cherrypick a range of commits. From the