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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:20:22+00:00 2026-05-11T05:20:22+00:00

How can I do the following in Git? My current branch is branch1 and

  • 0

How can I do the following in Git?

My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become local changes on branch2 without committing them on branch1?

  • 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. 2026-05-11T05:20:23+00:00Added an answer on May 11, 2026 at 5:20 am

    Since your files are not yet committed in branch1:

    git stash git checkout branch2 git stash pop 

    or

    git stash git checkout branch2 git stash list       # to check the various stash made in different branch git stash apply x    # to select the right one 

    Above is the longer more explicit version of rbento‘s answer:

    git stash git stash branch branch2 

    It uses:

    git stash branch <branchname> [<stash>]

    • Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created,
    • applies the changes recorded in <stash> to the new working tree and index.

    If that succeeds, and <stash> is a reference of the form stash@{<revision>}, it then drops the <stash>.

    This is useful if the branch on which you ran git stash push has changed enough that git stash apply fails due to conflicts.
    Since the stash entry is applied on top of the commit that was HEAD at the time git stash was run, it restores the originally stashed state with no conflicts.


    As commented by benjohn (see git stash man page):

    To also stash currently untracked (newly added) files, add the argument -u, so:

    git stash -u 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Git repository on my local machine that I cloned from my
Can I embed the following bash shell code: for name in $(git diff --name-only
If use MongoRepository, You can have following code: @Repository public interface UserRepo extends MongoRepository<User,
I have several files which is causing a compile error, can the following be
I have a remote web server that I have full access to (ssh, git,
I mistyped a git command which resulted in the creation of a local branch
I periodically get message from git that look like this: Your branch is behind
This question is based on the thread . I have the following Git-prompt at
Torvalds seems to have the following prompt . [torvalds@g5 git]$ The first word is
I know that I can view the difference between HEAD and current state with

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.