Skip to main content
2539 votes
19 answers
1.2m views

When is it recommended to use Git rebase vs. Git merge? Do I still need to merge after a successful rebase?
6 votes
1 answer
809 views

I have performed the following merge: A---B---C---E (HEAD, merge of C and D) / D---| But I noticed some issues in E, and fixed them in F: A---B---C---E---F (HEAD) / ...
3 votes
1 answer
126 views

I have added some notes to commits using git notes add <hash> -m potato But when I rebase or amend the commits, the note is not copied over to the new rewritten commit. According to the docs ...
4460 votes
22 answers
2.4m views

How do I easily undo a git rebase? A lengthy manual method is: checkout the commit parent to both of the branches create and checkout a temporary branch cherry-pick all commits by hand reset the ...
1 vote
4 answers
82 views

If I have merge conflicts, how can I take all changes from HEAD for a single file? Not for the whole rebase, but for a single file? Is this possible, or do I have to manually change it?
831 votes
25 answers
603k views

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 ...
530 votes
11 answers
219k views

I was working on a repository on my GitHub account and this is a problem I stumbled upon. Node.js project with a folder with a few npm packages installed The packages were in node_modules folder ...
0 votes
1 answer
96 views

While doing lots of branch-management via rebasing I have a number of common situations that cause merge conflicts to occur for which I have developed helper scripts that resolve the situation. When ...
272 votes
9 answers
86k views

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 ...
4 votes
3 answers
98 views

Note: I have already looked at the following answers and they don't seem to apply or work in the way I expect them to work: Reword one commit prior to merge Squashing old git commits that were before ...
182 votes
6 answers
354k views

My Git history looks like that : I would like to squash the purple commits into a single one. I don't want to see them ever again in my commit log. I've tried to do a git rebase -i 1, but even though ...
2 votes
1 answer
100 views

I pulled from origin main, and I'm having issues handling conflicts on my branch. I did the following git checkout test (name of my branch) git pull origin main It tells me I have conflicts and is ...
0 votes
2 answers
83 views

UPDATE: The 1st question below has been resolved. My remaining question is what is the best way to rebase a fork before I submit a PR to a FOSS project so my changes (of multiple commits and sync's) ...
-2 votes
1 answer
135 views

My history is linear: ... — B — C I make an interactive rebase to B~1 and set to edit B, pick C. All I do with B is to add a file to the gitignore, rm --cache -r . and commit --amend --no-edit it. ...
356 votes
10 answers
276k views

I have noticed that the two blocks of following git commands have different behaviours and I don't understand why. I have an A and a B branches that diverge with one commit ---COMMIT--- (A) \ --- (B) ...

15 30 50 per page
1
2 3 4 5
119