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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:06:15+00:00 2026-05-27T19:06:15+00:00

I cloned a git repository from GitHub, made some changes and some commits; I

  • 0

I cloned a git repository from GitHub, made some changes and some commits; I made quite a lot and all are quite dirty, so they’re not suitable for a pull request. Now I created the branch cleanchanges from origin/master, so it’s clean, and I want to commit my changes there as one commit with a nice commit comment.

When I am on the local master, I want to switch to my cleanchanges but without changing the files. And then I’m able to commit.

How can I switch branches without changing files?

I want to make it clear: I have all the changes committed in the local master. There are no uncommitted changes.

  • 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-27T19:06:16+00:00Added an answer on May 27, 2026 at 7:06 pm

    Edit: I just noticed that you said you had already created some commits. In that case, use git merge --squash to make a single commit:

    git checkout cleanchanges
    git merge --squash master
    git commit -m "nice commit comment for all my changes"
    

    (Edit: The following answer applies if you have uncommitted changes.)

    Just switch branches with git checkout cleanchanges. If the branches refer to the same ref, then all your uncommitted changes will be preserved in your working directory when you switch.

    The only time you would have a conflict is if some file in the repository is different between origin/master and cleanchanges. If you just created the branch, then no problem.

    As always, if you’re at all concerned about losing work, make a backup copy first. Git is designed to not throw away work without asking you first.

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

Sidebar

Related Questions

I've just cloned a repository, made some changes and now I'd like to send
I cloned a Git repository from my GitHub account to my PC. I want
I cloned a project from github with git clone --mirror . That left me
I am making changes to some file in my local git repository and then
I cloned a git respository on my hard disc. This git repository contains not
I made the move from SVN to Git for some home programming, setting up
Repository A: migrated to git from a project's SVN at revision r : cloned
When trying to clone ANY repository via https from github, we get: git clone
I cloned a read-only Git repo from GitHub onto my server. The next day,
I'm struggling to understand how to be able to clone a git repository from

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.