You might need this mostly if you are unable to pull since the project is not clean. In short, you can use “git reset –hard” to get back to the last commit. But, you can loose the changes you recently made.
Before doing this, I recommend stashing your changes first.
1. Optionally, to get latest info from remote server:
git fetch
Code language: Bash (bash)
2. Get to the final commit on master:
git reset --hard origin/master
Code language: Bash (bash)
or to any specific commit:
git reset --hard <commit_id>
Code language: Bash (bash)
or to another branch:
git reset --hard origin/<branch_name>
Code language: Bash (bash)
3. Cleanup the untracked files:
git clean -df
Code language: Bash (bash)
or cleanup all the other files including the ignored ones:
git clean -df
Code language: Bash (bash)
Leave a Reply