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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:35:12+00:00 2026-05-30T07:35:12+00:00

Master Branch had commits like this : A -> B -> C(HEAD) . HEAD

  • 0

Master Branch had commits like this : A -> B -> C(HEAD) . HEAD was at C.

What I did :

I checked out B and made commits on top of it.

Now the tree looks like this :

    A -> B -> C(master)(origin/master)
         |
         | -> B1 -> B2(HEAD)

git status on the project directory is giving me the following message :

# Not currently on any branch.
nothing to commit (working directory clean)`

So it means that B1 and B2 cannot be pushed. I got to know that this is happening because these commits doesn’t exist on any branch. Now, if I switch my branch back to master will these commits be lost? I am expecting a few more commits(B3, B4 ... BN) on these unnamed branch after which I want C to come on top of it. In essence, I would like to see the master branch in this way :

    A -> B -> B1 -> B2 -> B3 -------> BN -> C(master)(origin/master)

or atleast this way :

    A -> B ---------------------> C(master)(origin/master) -> D
         |                                                    ^
         |                                                    |
         | -> B1 -> B2 -> -> ...->BN--------------------------

What options I have to accomplish this? I want to be able to save the commits in the origin.

Any suggestions/directions is appreciated.

  • 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-30T07:35:13+00:00Added an answer on May 30, 2026 at 7:35 am

    Your desired outcome

    A -> B -> B1 -> B2 -> B3 -------> BN -> C(master)(origin/master)
    

    is not possible unless you can rewrite C in the remote repo; doing this would cause problems for everyone else who has done work based on C.

    The second preference

    A -> B ---------------------> C(master)(origin/master) -> D
         |                                                    ^
         |                                                    |
         | -> B1 -> B2 -> -> ...->BN--------------------------
    

    is easy: as Magnus says, you’ll make your life much easier if you give B2 (or whatever is the current latest commit in your sequence) a branch name: this is just easier to remember and type than the hash, and will make sure it doesn’t get garbage collected.

    git checkout -b bbranch
    
    A -> B -> C(master)(origin/master)
         |                                                    
         |                                                    
         | -> B1 -> B2 (bbranch)
    

    Now, if you want to push B1 and B2 to origin for whatever reason, you can merge and push as normal

    git checkout master
    git pull
    git merge bbranch
    
    A -> B ------> C -> D (master)
         |             /
         |            /
         | -> B1 -> B2 (bbranch)
    
    git push
    

    You can keep working on bbranch and merge again when you’re done with it

    A -> B ------> C -> D -> E -> ... -> En -> F (master)
         |             /                      /
         |            /                      /
         | -> B1 -> B2 -> B3  ->  ...  -> Bn  (bbranch)
    

    Note: if you want to push your commits to origin for whatever reason, but you don’t want them on master, you can simply push bbranch and it’ll take your commits with it. You’ll then either need to be sure that no-one else will touch bbranch, or to make your local copy a remote-tracking branch.

    Replace the merge step B2 -> D with git push origin bbranch in this case.

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

Sidebar

Related Questions

I made 5 commits to Master branch when bug hunting on a private project
I work 100% with a branch that I made off of the master branch.
I have a repository where I had been working on master branch having last
I have my master branch and my verydifferentbranch these had the same ancestor ...
I had a local branch which was branched off master quite some time ago,
I have had this happen to me often. I am working on a master
I have a master branch in my project, that I use to pull changes
Given I have a master branch and a other branch. In the other branch
I've a master branch with a .gitignore file with directory X listed in it.
Somehow my master and my origin/master branch have diverged. I actually don't want them

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.