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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:12:11+00:00 2026-06-17T22:12:11+00:00

I had to go back six commits in Git with the command git checkout

  • 0

I had to go back six commits in Git with the command

git checkout idofthecommit

What I have been doing was continuing commit, commit, commit. Since I have created no real new branch, when I git push to external repositories with

git push origin master

it tells me that everything is up-to-date.

This means I haven’t actually made any changes in the master.

How I can move the commits I have been doing to the master branch?

  • 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-06-17T22:12:12+00:00Added an answer on June 17, 2026 at 10:12 pm

    If your description of the commands you ran is correct – create a branch now on what you’ve been working on to create a reliable named reference to it (git branch WIP HEAD). Then rebase against master (git rebase master) and checkout master and merge in WIP.

    You can test this out fairly simply to replicate the situation and explore the commands you need and what they do. For this git graph is aliased to git log --graph --oneline --decorate --abbrev-commit and just produces a pretty git log.

    Create a demo repository with 8 commits then checkout six back and create some more commits

    $ cd /tmp && git init demo && cd demo
    $ for msg in one two three four five six seven eight; do echo $msg>file && git add file && git commit -m $msg; done
    $ git checkout HEAD~6
    $ for msg in nine ten eleven; do echo $msg>file && git add file && git commit -m $msg; done
    

    So lets just look at this:

    $ git graph --all
    * e81b31c (HEAD) eleven
    * c005e75 ten
    * c567d25 nine
    | * 4d28c3d (master) eight
    | * 380f715 seven
    | * 9966c80 six
    | * 6b2f757 five
    | * e43d079 four
    | * ce0ff34 three
    |/
    * 8d5a6e1 two
    * 1f880ae one
    

    So really this just looks like a feature branch taken from 8d5a6e1. The only special thing is its only reference is HEAD. If you now add a branch reference it will become a normal feature branch.

    If you accidentally checkout master or some other branch before you labelled this working branch with a branch tag then you would loose the reference to the top of this new chain of commits. Now you lost the branch. In this case you need to use the reflog to find the last commit on that chain and add a branch reference to that commit. We can see this from the demo repository above:

    $ git reflog
    e81b31c HEAD@{0}: commit: eleven
    c005e75 HEAD@{1}: commit: ten
    c567d25 HEAD@{2}: commit: nine
    8d5a6e1 HEAD@{3}: checkout: moving from master to HEAD~6
    4d28c3d HEAD@{4}: reset: moving to 4d28c3d
    ....
    

    We can see from the reflog that a few commits back, we checked out HEAD~6 and then added three more commits. We could then issue git branch recover-commits e81b31c to get a branch that points to that set of commits and recover them.

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

Sidebar

Related Questions

I had asp.net back ground and now developing apps for Iphone. I have been
A while back, smart clients had been touted as the solution to occasional connected
I have been tasked with taking an Access 97 application and moving the back-end
I have been programming in Python for a while now, and have created some
[EDIT] Alright, I edited this post since the code I posted back then had
I have first encounter operator overloading in .Net, long back I had used it
I remember seeing a poster a few years back that had a nice break
I had a similar question a while back, but with much less of a
Back in MVC3, I had a custom ControllerFactory which would use my own container
a while back, CNET had these really cool Social Share buttons, that when you

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.