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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:20:02+00:00 2026-05-26T12:20:02+00:00

I have a project tracked in git that has a master branch that becomes

  • 0

I have a project tracked in git that has a master branch that becomes the release for my code. I have some code in that branch that is causing problems because an external library that it relies on is currently broken. However, I expect that the external library will be “fixed” at some point in the future (weeks, so stash is not really what I want here) and that I will want to resurrect the problematic code.

So, the question:

How can I save code from a branch for future use? If I simply create a branch called saveme, make changes on the master branch, and then try to merge saveme back into master to get back the “saved” code, this seems to result in “already up-to-date”.

  • 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-26T12:20:02+00:00Added an answer on May 26, 2026 at 12:20 pm

    When you create the saveme branch, your history looks like this:

     A -- B -- C (saveme,master)
    

    …. then when you work more on master, to cope with the broken library, your history looks like this:

     A -- B -- C (saveme) -- D -- E (master)
    

    So if you try to then merge saveme into master, it says “Already up-to-date” because the complete history of saveme is already contained in master. It sounds as if what you want is to then create a commit which has exactly the same tree as saveme, but is just another commit on top of master. You could do this by using git revert for commit E and then D, but if you want to do it in one go, you can do the following:

    # Check that "git status" is clean:
    git status
    
    # Set the index (staging area) to be as it was at the tip of the branch saveme:
    git read-tree saveme
    
    # Create a commit based on that index:
    git commit -m "Going back to the state of the branch 'saveme'"
    
    # Your working tree will still be as it was when you started, so
    # you'll want to reset that to the new commit:
    git reset --hard
    

    (This is a trivial variation of the recipe I suggested in this answer.) Then your history will look like:

     A -- B -- C (saveme) -- D -- E -- F (master)
    

    … but the tree of commit F will be the same as that of commit C.

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

Sidebar

Related Questions

I have a project where a .master page was created without a code behind
Some Background I have been using Git for a while now. The projects that
Use case: we have some project meta-data files which we want tracked, but are
I have cloned a project that includes some .csproj files. I don't need/like my
We have several branches of one project that share about half of the code
I have project that I'm working on that is going to require a webserver.
I have a project that I'm currently working on but it currently only supports
I have a project that I would like to start beta testing soon, it
I'm working on a web site project that is currently tracked in svn but
I'm working on a project that runs on Rails ~> 3.0 on the master

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.