git-rebase

How do I use Git's interactive rebase with a local-only repository (no remote / origin)?

99封情书 提交于 2019-11-29 02:13:32
问题 I use git as a local source control system mostly for history and diff tracking. I still want to use rebase to do fixup / squash on WIP commits that I will make periodically. When I try to do git rebase -i though, I get the following: There is no tracking information for the current branch. Please specify which branch you want to rebase against. See git-rebase(1) for details git rebase <branch> If you wish to set tracking information for this branch you can do so with: git branch --set

Git: Cannot rebase because of uncommitted changes

霸气de小男生 提交于 2019-11-29 01:44:49
问题 Git won't let me rebase from anywhere. Cannot rebase: Your index contains uncommitted changes. Please commit or stash them. Following the instructions from this answer: https://stackoverflow.com/a/13694625/618450 $ git update-index -q --ignore-submodules --refresh $ git diff-files --ignore-submodules Both do not produce any output but that one does: $ git diff-index --cached --ignore-submodules HEAD -- :100644 000000 cab819f1e5ed6cc7cff374eecae273e1d6ae6a01

Remove spurious commit parent pointer

扶醉桌前 提交于 2019-11-29 01:42:58
I imported a Bazaar repository into Git (using git bzr ), but the resulting repository contains a spurious commit parent link: Notice that the commit tagged 1.02-6 is based off the 1.02-3 commit, but 1.02-1 is unnecessarily also marked as a parent. (Note: All the commits in this part of the repo are tagged; there are no commits between the ones shown.) I have tried rebasing in several ways (on the master branch: git rebase 1.02-3 , git rebase -i upstream-1.02 , git rebase --onto 1.02-1 1.02-3 , git rebase --root upstream-1.02 --onto=other_branch ), but in each case it fails with a merge

Why do I have to resolve the same conflict over and over?

隐身守侯 提交于 2019-11-29 01:27:58
问题 When I do git rebase branch1 in my branch1-local I get conflicts. I solve the conflict, do git add <conflicted-add> and then do git rebase --continue as git asks me to do. After that a new commit is applied. A new conflict shows up. But is the same conflict again! the same file!. I do it again, git add , the git rebase --continue , and then it all repeats again until I do repeat this for each commit being rebased on. Why rebase is having me redo the same conflict resolution over and over

Git interactive rebase without opening the editor

半世苍凉 提交于 2019-11-29 01:16:26
Git allows certain commands to create or modify commits without opening the editor first, for example: git commit --amend --no-edit git commit --fixup=HEAD^ I have set rebase.autosquash to true , so that the todo list for an interactive rebase is automatically reordered. Is there a way to immediately perform the rebase, without opening the editor first, something like: git rebase -i --no-edit HEAD~3 TL;DR answer: GIT_SEQUENCE_EDITOR=: git rebase -i HEAD~3 You can't stop git rebase --interactive from running the "sequence editor" (that's the edit command on the "sequence file" containing the

Combine or rebase an arbitrarily large number of commits

谁说胖子不能爱 提交于 2019-11-28 23:19:45
问题 Let's say my local git log shows: 739b36d3a314483a2d4a14268612cd955c6af9fb a ... c42fff47a257b72ab3fabaa0bcc2be9cd50d5c89 x c4149ba120b30955a9285ed721b795cd2b82dd65 y dce99bcc4b79622d2658208d2371ee490dff7d28 z My remote git log shows: c4149ba120b30955a9285ed721b795cd2b82dd65 y dce99bcc4b79622d2658208d2371ee490dff7d28 z What's the easiest way to get to this ( assuming an arbitrarily large number of local commits ): 527b5810cfd8f45f18ae807af1fe1e54a0312bce a ... x

Git: move a commit “on top”

丶灬走出姿态 提交于 2019-11-28 19:16:23
Let's say in master I have a feature disabled. I work on that feature on branch feature , so I have a special commit $ there that just enables that feature. Now I want to merge the changes I did in feature into master , but keep the enabling commit out. So it's like main: A--B--X--Y feature: A--B--$--C--D So let's say I want to do it, by moving the $ commit on top of feature: new feature: A--B--C--D--$ How would I go about doing that? git rebase -i B , and then move $ to the end of the list that shows up in your editor. It will start out as the first line in the file that opens. You could also

How to avoid git rebase killing merge commits?

时间秒杀一切 提交于 2019-11-28 18:44:57
问题 Given the following git history: C-I origin/master / A-B-F-G-H master \ / D-E branch-b I want to rebase my local master branch on top of origin/master , but I want to preserve the merge commit G . When I tried simply doing a git rebase origin/master while at master it squashed D..E as G and committed that with the commit message of E , so the history that there was a merge was lost. Is there some way of preserving this merge while still getting the rebase? For clarity, my intended result is:

git rebase upstream/master vs git pull --rebase upstream master

﹥>﹥吖頭↗ 提交于 2019-11-28 17:23:54
问题 Is there a difference between git rebase upstream/master and git pull --rebase upstream master , and if so, what? The remote could be any remote, not necessarily upstream. 回答1: The git pull --rebase will fetch (git fetch) first, updating upstream/master commits. If you just rebase without first updating upstream/master , you won't get the same result. I illustrate it in "master branch and 'origin/master' have diverged, how to 'undiverge' branches'?" SnakE mentions in the comments that git

Git - How to fix “corrupted” interactive rebase?

拜拜、爱过 提交于 2019-11-28 17:20:47
I managed to create a little mess in my local git repository. I was trying to fix a broken commit by using the following instructions . Before running the "git commit --amend" (and after the git rebase --interactive) I decided that my changes were incorrect and so I executed "git reset HEAD --hard". Not a good idea, I tell you. Now the interactive rebase seems to be "stuck". Git shows the current branch as (|REBASE-m). Every command (cd .., ls, git rebase...) inside my repository gives the following error: cat: .git/rebase-merge/head-name: No such file or directory Here's how git rebase -