Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1114907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:04:36+00:00 2026-05-17T03:04:36+00:00

git rebase does not appear to work properly in certain cases where a file

  • 0

git rebase does not appear to work properly in certain cases where a file is added to the repository, then removed from the repository, then added to the working directory (but not the repository).

Here’s a more specific description of my problem:

  • if a branch is created and switched to from some
    trunk,

  • and a file X is added and committed
    in the branch,

  • and subsequently X is removed and
    committed in the branch,

  • and X is again created in the working
    directory, but not added or
    committed,

  • and the trunk branch advances,

  • then

  • a rebase performed using the advanced
    trunk as the base will fail because
    it will refuse to overwrite X,

  • and the rebase cannot be continued
    even if the working directory X is
    removed or moved out of the way.

Here’s a script to reproduce my problem on the command line:

git init
echo foo > foo.txt
git add .
git commit -m 'foo'
echo foo >> foo.txt
git add .
git commit -m 'foo foo'
git checkout -b topic HEAD^
git log
echo bar > bar.txt
echo baz > baz.txt
git add .
git commit -m 'bar baz'
git rm bar.txt
git commit -m '-bar' 
echo bar > bar.txt
git rebase master 
# the following output is emitted:
# First, rewinding head to replay your work on top of it...
# Applying: bar baz
# Using index info to reconstruct a base tree...
# Falling back to patching base and 3-way merge...
# error: Untracked working tree file 'bar.txt' would be overwritten by merge.  Aborting
# Failed to merge in the changes.
# Patch failed at 0001 bar baz
# 
# When you have resolved this problem run "git rebase --continue".
rm bar.txt
git rebase --continue
# the following output is emitted:
# Applying: bar baz
# No changes - did you forget to use 'git add'?
# 
# When you have resolved this problem run "git rebase --continue".
# If you would prefer to skip this patch, instead run "git rebase --skip".
# To restore the original branch and stop rebasing run "git rebase --abort".

I know I can abort the rebase using git rebase --abort, remove bar.txt, and then git rebase master again. But how can I continue the rebase without aborting it first?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T03:04:37+00:00Added an answer on May 17, 2026 at 3:04 am

    I found a solution: apply the troubled commit’s patch manually and add it to the index.

    $ patch -p1 < .git/rebase-apply/patch 
    patching file bar.txt
    patching file baz.txt
    $ git add bar.txt baz.txt
    $ git rebase --continue
    Applying: bar baz
    Applying: -bar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What does it mean when a git rebase finds a conflict, but there is
I'm not clear on what the following means (from the Git submodule update documentation):
Related question: why does Git send whole repository each time push origin master The
In Git, I sometimes work on long-running branches. I like to rebase on master
I just squashed some commits with git rebase and did a git push --force
I've already looked at questions git rebase and git push: non-fast forward, why use?
I simply want to edit some commits with git rebase -i HEAD~2 inside the
I get following error message, when I try to run git rebase -i for
I understand that when I use git pull --rebase , git will re-write history
I know of some people who use git pull --rebase by default and others

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.