1,775 questions
2
votes
1
answer
103
views
How to rebase a branch with heavy changes onto a branch that moved the target directory?
How to rebase a branch which changes files in directory backend onto a branch which moved the directory backend to apps/backend?
I have two branches: main and work. Their common ancestor commit R had ...
3
votes
5
answers
258
views
git rebase conflict take all changes from head on single file
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?
4
votes
1
answer
183
views
How to keep git notes through a rewrite (rebase/rename/amend)?
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 ...
0
votes
1
answer
109
views
Is there a way to run a command if a rebase step fails with a merge conflict?
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 ...
4
votes
3
answers
113
views
Looking for a clean way to reword a few commits from before multiple merges were done without having to re-resolve conflicts
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 ...
2
votes
1
answer
189
views
Why does "git rebase" continue to conflict after choosing the "--ours" version of a file the first time?
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
90
views
How to rebase/? a fork of a FOSS project so when I submit a PR my multiple commits/syncs show as 1 commit? [closed]
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
148
views
I only edit one commit in an interactive rebase and pick the rest. What makes the result squashing them into one?
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. ...
0
votes
1
answer
66
views
`git rebase --interactive` always use rebase-then-squash workflow and introduce many conflict resolution, how to switch to squash-then-rebase?
Here is a typical example of executing git rebase --interactive --autosquash:
git rebase --interactive --update-refs origin/master
Rebasing (1/102)
Rebasing (2/102)
error: could not apply eff00df3... ...
0
votes
2
answers
212
views
Safest way to resolve push conflicts and messy commit history after rebasing local branch with updated main?
I recently rebased my local feature branch onto the latest main branch to get up-to-date. Now, my commit history looks all weird—some commits seem duplicated or out of order, and when I try to push, I’...
6
votes
1
answer
161
views
Git rebase removes an empty conflict resolution despite options `--empty=keep` and `--keep-empty`
I have a script that does a git rebase with the flags --empty=keep and --keep-empty. It's important that no commit is dropped because the script later relies on relative refs (like HEAD~3) and on the ...
0
votes
1
answer
139
views
What does `git diff` actually compare during a rebase conflict?
I have recently learned that git diff --cached shows how the new commit during an interactive rebase conflict after resolving the conflict looks. What does git diff compare during resolving a git ...
1
vote
1
answer
58
views
Git-rebase fails multiple times each rebase, claiming deleted files will be overwritten, but the working tree is clean and `--continue` works. Why?
I apologize, the situation I am about to lay out below is probably very confusing, because I am very confused myself. As this is related to work, I cannot provide the actual repository.
Summary of the ...
1
vote
3
answers
122
views
How to remove other branch commits?
I was reading through code when I found an issue, and had forgotten to pull the main branch before opening my branch to make my fix, and commit. I noticed when opening the PR that there were latent ...
3
votes
3
answers
159
views
Can squash commits be done in both directions of the timestamp?
Say there is a squash of 3 commits into a single commit like so:
pick abc Jan 1 stuff
squash def Jan 2 stuff
squash ghi Jan 3 stuff
pick jkl Jan 4 stuff
pick mno Jan 5 stuff
In the above, my ...
-3
votes
2
answers
114
views
Why is git autosquash not working as expected? [closed]
Update
My company adds a prefix to the commit history which i had gotten so used to, I didn't see it but of course git would, and that was causing the issue. Removing that prefix fixed my issue.
...
2
votes
1
answer
113
views
accidentally created & changed to a new git branch while rebasing
I was mid-rebase, let's say on branch foo, and I accidentally ran git checkout -b net5, and somehow it proceeded successfully!
(I intended to type this command into a different console window.)
Now I'...
0
votes
1
answer
75
views
Heroku Git-LFS push error, mistakenly added git-lfs to app, then pushed pdfs, now hung in build = crash
After git push heroku main even with force:
batch response: Repository or object not found: https://git.heroku.com/app.git/info/lfs/objects/batch
Check that it exists and that you have proper access ...
0
votes
0
answers
26
views
Is it possible to stash an ongoing rebase [duplicate]
I started a complicated rebase, it'll take hours. However, we asked me to do a little fix on the develop branch.
Is is possible to stash my ongoing rebase so that I can do the little fix an come back ...
3
votes
1
answer
122
views
When removing a file from history, what makes it still left in tree?
I have a private file that leaks into the repo, and I want to delete it. Here are the commits I suppose that it is first added:
git log --follow --diff-filter=A --find-renames=40% --pretty=reference --...
2
votes
0
answers
134
views
`git log` shows commits not upstream any branch or tag
I often watch git log --all --oneline --graph --decorate --colors to keep an eye on my rebases. Today, something rather unsettling is showing up:
* b782b84 (HEAD -> dev, origin/dev) III
* 22fe431 ...
0
votes
2
answers
171
views
Rebasing branch from later branch back onto master directly
After updating my local master, I routinely rebase my local branches.
However, this time, I forgot to checkout master back between rebases and rebased one local non-master branch (branch_2 in my ...
2
votes
2
answers
100
views
Undo commit B keeping commits C and D
Say my commit history looks like this:
A -- B -- C -- D (HEAD)
With a file test.txt, where each letter was added in the respective commit
A
B
C
D
Without changing the git history (just changing the ...
1
vote
2
answers
104
views
Git dev branch 1 commit behind master [closed]
I have a github repository with a master and dev branch. When I'm working I usually make a change on dev branch. After I'm done, I create a pull request (PR) to master and merge it.
The problem is one ...
-3
votes
1
answer
151
views
Git cherry-pick multiple commits without manually copy-pasting hashes
I have two branches, X and Y, and I want to cherry-pick a bunch of commits from Y to X, say, C..F, H, M. I can achieve this with:
git switch X
git log Y
# Look up commits of interest
git cherry-pick C....
0
votes
1
answer
318
views
How to drop changes to submodule ref from commit during rebase
I'm rebasing my branch on origin/master using
git pull --rebase origin master
Now I get some merge conflicts regarding git submodule updates:
diff --cc cpp_lib
index c14a3fe5,71b17a71..00000000
--- a/...
0
votes
1
answer
1k
views
Changes from the main branch appearing in PR after rebase (pulling after a rebase)
I created a new branch feature from main and pushed some changes. Later, I noticed that main had new commits, so I wanted to update feature accordingly. Here's what I did:
Checked out main and ran ...
1
vote
1
answer
73
views
Git Rebase but keeping some changes from feature branch
I have a main branch and a feature_branch.
I did:
git checkout feature_branch
git rebase main
What I want to do is get all changes from main for all files but 1, keep changes done in feature_branch ...
-1
votes
2
answers
114
views
git rebase --rebase-merges produces merge conflicts
I have a git repository that has two branches with unrelated history like this
A'
A - B - [...] - C
where the [...]-part is complicated (non-linear and many commits). Both the commits A and A' are ...
-3
votes
1
answer
143
views
Git squash/merge feature into develop [duplicate]
I have two branches
feature/abc
and
develop
They both have different unrelated histories. I want to squash all commits that are in feature/abc and then merge or rebase the single commit into ...
-2
votes
3
answers
125
views
Rename detection makes `git rebase` remove a random file
I have a script that among other things uses git rebase to remove a specific commit from the current branch.
In one case, it removes a seemingly random file.
After long debugging session, I've managed ...
1
vote
2
answers
502
views
Why do I get "invalid command 'git'" after editing the "rebase todo" and trying to continue?
I tried to switch my branch but I could not because I was rebasing:
fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".
It showed:
Next ...
1
vote
1
answer
132
views
git error: Your local changes to the following files would be overwritten, to file that wasn't change on remote
We are using VSCode in our project, we have .vscode/tasks.json tracked on the server just to make sure everyone is aligned with the same configuration.
Since I wanted to add new tasks (just for me), I ...
1
vote
1
answer
94
views
Git Rebase Dilemma: Sort out the tangled feature branches
I had a feature branch which was based off of develop, let's call it feature-1. At the same point in time I also took another feature branch feature-2.
feature-1 was a real feature branch that I've ...
0
votes
1
answer
55
views
Git rebase over a commit that extracts files into submodule
I've got a git history like so:
commit 027dbda16679e8c737c8ec63676aa564807cfaeb (HEAD -> master)
Author: Camden Narzt <[email protected]>
Date: Thu Dec 19 15:36:42 2024 -0700
migrate ...
1
vote
1
answer
55
views
How to rebase a git branch that contains a merge commit *and* corresponding, previous branch-point
I am trying to interactively rebase commits from the branch tmp/20241220-rebase-source onto tmp/20241220-rebase-target.
The commits to rebase include a branching point and corresponding merge-commit (...
1
vote
1
answer
35
views
$REMOTE point to different branches in git merge vs. rebase?
I want to configure kdiff3 to use a specific order for windows (from left to right): $REMOTE | $BASE | $LOCAL. However, I encountered an issue where $REMOTE differs between merge and rebase commands.
...
-1
votes
1
answer
243
views
How do I rebase the remote branch onto the local branch when doing git pull?
I want any extra remote commits to be added after any commits done locally.
I have achieved this by doing
git fetch origin
git checkout -B newmain origin/main
git rebase main
git push -...
1
vote
2
answers
643
views
Correct way to store .gitattributes (working-tree-encoding) after many commits?
There is a large Git repository (~4,000 commits) containing files in CP866 and does not contain a file named .gitattributes in the root of project. Is there any way to add .gitattributes (*.txt text ...
0
votes
1
answer
113
views
How to change a merge commit message after merging and deleting the branch in gitlab
I want to correct a typo in a merge commit message in gitlab. The original branch doesn't exist anymore since it was deleted after merging. I can edit the squash commit message using its SHA and an ...
0
votes
1
answer
98
views
Merging divergent branches without rebase
I have the following git situation:
I was working on a branch, say profiles taken from master. The profiles branch has the profiles feature.
While working I commit a million times every small change. ...
0
votes
2
answers
87
views
How does git rebase handle amended commits without conflicting
Consider the following example:
I change a file and change content X to A and push this change
Somebody else pulls and changes A to B
They amend or squash these changes and force push, so now on ...
2
votes
2
answers
129
views
Why do I get merge conflicts when rebasing onto an empty commit with `rebase-merges`?
We're transferring an old repository and as part of that we want to make a review of all existing code. The first commit is not empty, so we created a new root commit on main that is empty so that we ...
0
votes
0
answers
75
views
Setting a `sed` command as `GIT_EDITOR` doesn't work correctly in `git rebase --interactive` [duplicate]
I have the following Git repository (git log --oneline):
658f9f0 (HEAD -> master) baz
4da6df7 bar
4f95d1b foo
When I run the command:
GIT_EDITOR='sed -iEn "2 p" --' git rebase --...
1
vote
1
answer
90
views
Rebase part of one repository history on top of a similar but different repository
We have a couple of repositories, let's call them RA and RB which are similar but not the same. RA is a export of an SVN repostiory were some libraries were extracted in the export process and RB is ...
1
vote
3
answers
248
views
How to git pull rebase when I have deleted files locally?
I'm working on an XCode project, and I want to push my local changes.
However, my local and remote branch had diverged before I made local changes, so I understand that I have to do a 'git pull and ...
2
votes
3
answers
134
views
How to delete a merge commit from git history?
My git history looks like this:
A---B--------D---F
\ / /
\____C/__E/
Where head is now at F, and D and F are merge commits. I forget a rebase at E from D, but only realized after ...
0
votes
0
answers
34
views
How to rewrite commit history from origin master branch [duplicate]
My origin master looks like
A -> B -> C -> D
I want to remove the commits C and D so that my origin master will be like below
A -> B
I have tried do the hard reset and force push as below
...
-4
votes
1
answer
113
views
Does git rebase Update All Commit IDs? [duplicate]
I know git rebase will update the SHA of the affected commits. But, correct me if I'm wrong, the parent commits will be updated too, then their parents would update, and so on. So, does the entire ...
1
vote
1
answer
108
views
Checking a PR's commits are all descendants of destination branch
In our team we have a requirement for our PRs: they need to be rebased before being merged, in order to achieve a "semi-linear history". I'm looking for an automated way to evaluate this ...