Git interactive rebase without opening the editor

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 various pick, etc., commands). However, if you examine the interactive rebase script: $ vim $(git –exec-path)/git-rebase–interactive you’ll find code like this near line 230 or so: git_sequence_editor … Read more

How do I git rebase the first commit?

The easy way, with a recent-enough Git (this has been out for a long time now so you should have this): git rebase -i –root The other easy way, as twalberg noted in a comment that has since been deleted but is now expanded in https://stackoverflow.com/a/68279810/1256452’s answer, is to use git checkout –orphan to set … Read more

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

You can use this with Git v1.7.3 or later versions. git rebase –strategy-option theirs ${branch} # Long option git rebase -X theirs ${branch} # Short option (which is a short for git rebase –strategy recursive –strategy-option theirs ${branch} as stated by the documentation) From Git v1.7.3 Release Notes: git rebase –strategy <s> learned the –strategy-option/-X … Read more

Git rebase fails, ‘Your local changes to the following files would be overwritten by merge’. No local changes?

This is the same answer as another one of my questions re git troubles. I’m on a mac, and this obscure config change seemed to fix all my woes regarding unstaged changes when there were none. git config –global core.trustctime false I think it’s to do with differences between windows file times, linux file times … Read more

Choose Git merge strategy for specific files (“ours”, “mine”, “theirs”)

For each conflicted file you get, you can specify git checkout –ours — <paths> # or git checkout –theirs — <paths> From the git checkout docs git checkout [-f|–ours|–theirs|-m|–conflict=<style>] [<tree-ish>] [–] <paths>… –ours –theirs When checking out paths from the index, check out stage #2 (ours) or #3 (theirs) for unmerged paths. The index may … Read more