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.
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?