Truemag

  • Home
  • Angular JS
  • C Sharp
  • DevOps




What is the git command to move branch pointer to different commit without checkout ?

Git is a version control system that can be used for storing the source code at the centralized server or location, so that multiple members of the team can work on the application at the same time.

There will be scenarios where you will want to move the branch pointer to the different commit. So, we have two ways to resolve this.

Let’s say that you are working in your current branch which you have checked out from GIT. Then, we can make use of the git reset –hard command. Please find below a sample example of the git reset –hard command.

git reset --hard d17e40c50b442d84eca44210b4964770be229a19 

Now, lets say that you are in a separate branch and you want your branch pointer to point to a commit in some other branch. If you want to achieve this, then you can make the use of the git branch command. Please find a sample below showing how we can acheive this:

git branch -f master d17e40c50b442d84eca44210b4964770be229a19

Here, we are pointing to the master branch which is having a commit id of d17e40c50b442d84eca44210b4964770be229a19.

Related Reading

How to undo changes in Git?
How to remove untracked files in Git?
How to change remote origin in Git?
Staging area in Git?
What does git prune remote origin do?
What is git checkout?
how to track revisions in Git?
How to delete local branch in Git?

Apr 15, 2020Prashant Kumar
What command tracks the revisions in git ?How to delete local branch in git?
  • Case Statement in Azure DevOps
  • How to solve file not found error in Linux?
  • How to delete local branch in git?
  • What is the git command to move branch pointer to different commit without checkout ?
  • What command tracks the revisions in git ?

Sign up for our newsletter to receive the latest news and event postings.

Recent Posts
  • Case Statement in Azure DevOps
  • How to solve file not found error in Linux?
  • How to delete local branch in git?
  • What is the git command to move branch pointer to different commit without checkout ?
  • What command tracks the revisions in git ?
Recent Comments
  • How to change directory in git bash? - Prashant's Blog on How to delete local branch in git?
  • eebest8 on How to use Http Post in Angular 4

  • Case Statement in Azure DevOps
  • How to solve file not found error in Linux?
  • How to delete local branch in git?
  • What is the git command to move branch pointer to different commit without checkout ?
  • What command tracks the revisions in git ?
  • Home
  • Angular JS
  • C Sharp
  • DevOps
  • June 2020
  • April 2020
  • February 2020
  • July 2019
  • June 2019
  • May 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • July 2018
  • March 2018
  • February 2018
2018 © Prashant's Blog