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 894073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:19:23+00:00 2026-05-15T14:19:23+00:00

I have a git repository that I am using and I’ve screwed up. I

  • 0

I have a git repository that I am using and I’ve screwed up. I made a few patches to the source tree and then went on to do upgrades without committing the patches first. Then I committed the whole batch together as one. My intent was to be doing the upgrades on a separate branch, which I did create before the commit.

Now at this point I have two (relevant) branches master, which is still stable but needs patched. And I have new_auth_system which has two commits ahead of master. The first is full of patches I did yesterday and committed. The second has a few more patches and an incredibly large and obscure amount of deletions and additions across several files.

I’ve been trying to use git checkout to pull the specific files out of the commit and tack them onto a clone of master in an attempt to get things corrected but I keep getting “fatal: reference is not a tree”

How do I go about pulling specific files across commits and into another branch?

Thanks!

  • 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-15T14:19:23+00:00Added an answer on May 15, 2026 at 2:19 pm

    If your situation is:

     x--x--x--x (master, need patch)
            \
             y1--y2  new_auth_system, with y1 containing some patches *and* updates
                                      and y2 containing massive refactoring
    

    I would recommand first:
    (if you haven’t pushed new_auth_system already)

    • a rebase --interactive to split y1 into y1a (with only your patches) and y1b (updates), and y2 in y2a (more patches) and y2b (massive refactoring)
        git checkout new_auth_system
        git rebase -i y1^
    
         x--x--x--x (master, need patch)
                \
                 y1a--y1b--y2a--y2b  new_auth_system, with y1a containing only patches
                                                           y1b containing only updates
                                                           y2a containing only patches
                                                           y2a containing refactoring
    
    • a rebase --interactive to reorder ‘y’ commits (patches first, updates and refactoring second)
        git checkout new_auth_system
        git rebase -i y1a^
    
         x--x--x--x (master, need patch)
                \
                 y1a--y2a--y1b--y2b  new_auth_system, with patches first (y1a, y2a)
                                                           updates and refactoring second
    
    • a git merge to integrate those patches in master:
         x--x--x--x------x' (master, with patches)
                \       /
                 y1a--y2a--y1b--y2b  new_auth_system, with patches first, 
                                                           updates and refactoring second
    

    It is better than trying to isolate some files from one branch to another: Git reasons in term of project (a collection of files under a common tree), not in term of individual files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.