git-rebase

How to redo merge conflict resolution after working with unrelated commits that came before it with rebase -ir?

坚强是说给别人听的谎言 提交于 2021-02-08 08:53:16
问题 For a simple example, let's say we have a repo where an incorrect line was added to a file a . $ git init Initialized empty Git repository in /someplace/.git/ $ echo "a1\nb2" > a $ echo b1 > b $ git add . $ git commit -m init [master (root-commit) 917f3b9] init 2 files changed, 3 insertions(+) create mode 100644 a create mode 100644 b The branch master then forks off new branch f . $ git branch f In master , we then add another line to the incorrect file. $ echo b3 >> a $ git commit -am

Does a rebase the only way to fix a wrong cherry-pick?

♀尐吖头ヾ 提交于 2021-02-08 06:44:26
问题 The branch #1 contains a bug fix C1. The branch #2 first cherry-pick ed C1, then the branch #2 owner realised the work done in C1 was wrong actually, so he committed the correct fix C2. In C2 he basically removed the change in C1, replaced with the correct change. When the branch #1 owner wants to "pick-up" the fix, the merge won't work . Because with merge the result C3 will then contain C1 and the correct fix introduced in C2, i.e. C1 will be keep by merge. Because the branch #2 now does

Convert merge into rebase without having to perform the merge again

我的梦境 提交于 2021-02-05 18:29:00
问题 I made a mistake: I should have used git pull --rebase , but I issued a simple git pull , merged everything and now have a merge commit at the HEAD of my branch. I want to get rid of that merge commit and I thought I'd just issue a git rebase -i HEAD~3 , move my last local commit to the top and squash the merge commit into it. Alas, the merge commit is not available for squashing. If I do this, I get into intermediate states where I need to do the merge again, which is a lot of work. Is there

Convert merge into rebase without having to perform the merge again

烂漫一生 提交于 2021-02-05 18:09:20
问题 I made a mistake: I should have used git pull --rebase , but I issued a simple git pull , merged everything and now have a merge commit at the HEAD of my branch. I want to get rid of that merge commit and I thought I'd just issue a git rebase -i HEAD~3 , move my last local commit to the top and squash the merge commit into it. Alas, the merge commit is not available for squashing. If I do this, I get into intermediate states where I need to do the merge again, which is a lot of work. Is there

Convert merge into rebase without having to perform the merge again

北城余情 提交于 2021-02-05 18:08:03
问题 I made a mistake: I should have used git pull --rebase , but I issued a simple git pull , merged everything and now have a merge commit at the HEAD of my branch. I want to get rid of that merge commit and I thought I'd just issue a git rebase -i HEAD~3 , move my last local commit to the top and squash the merge commit into it. Alas, the merge commit is not available for squashing. If I do this, I get into intermediate states where I need to do the merge again, which is a lot of work. Is there

Convert merge into rebase without having to perform the merge again

耗尽温柔 提交于 2021-02-05 18:06:08
问题 I made a mistake: I should have used git pull --rebase , but I issued a simple git pull , merged everything and now have a merge commit at the HEAD of my branch. I want to get rid of that merge commit and I thought I'd just issue a git rebase -i HEAD~3 , move my last local commit to the top and squash the merge commit into it. Alas, the merge commit is not available for squashing. If I do this, I get into intermediate states where I need to do the merge again, which is a lot of work. Is there

Insert a NON-EMPTY commit before the root commit in Git?

落爺英雄遲暮 提交于 2021-01-29 08:59:59
问题 I have a problem, please be kind enough to advise! I have an existing git repo, and for various reasons(that I wont go into here), I am trying to create a ROOT commit Say this is my git commit history: (ROOT) C1 <-C2 <-C3 <-C4 <-C5 <--branchname (HEAD) I want to add an initial commit (CX, which is not empty) BEFORE C1. So it should end up like this: (NEW ROOT) CX-C1 <-C2 <-C3 <-C4 <-C5 <--branchname (HEAD) I found a similar question here: Insert a commit before the root commit in Git? But it

git rebase -i --retain-empty-commits

爷,独闯天下 提交于 2021-01-21 13:01:54
问题 By default, when you use git rebase -i it comments out empty commits and I have to uncomment them (they're helpful to me). Is there an option to the rebase command that will prevent this unwanted assumption that I don't want to preserve them? 回答1: Okay, that was easier than expected: git rebase -i --keep-empty Hopefully this post will speed up others Googling to find the answer. 回答2: With Git 2.26 (Q1 2020), " git rebase " has learned to use the merge backend (i.e. the machinery that drives "