
- Git switch branch and discard changes how to#
- Git switch branch and discard changes software#
- Git switch branch and discard changes Pc#

To pull from remote main branch: git pull origin mainĬommit - means adding a record entry of your changes e.g. To pull from your remote branch: git pull Pull - means getting latest changes from a remote branch into your branch ( git pull = git fetch + git merge) git merge is required to integrate these changes HEAD - head always refers to the latest commit on your current branch.įetch - just download latest changes from a remote branch in separate path and do not integrate with your repo. Main - it's the head branch named main (default created branch for any new repo, earlier it was used to be master)
Git switch branch and discard changes software#
Tag - you can create a tag when doing software releases Upstream - upstream is their main repo (from which you have forked, useful to get latest changes from their repo releases) Origin - origin is your remote repo (from where you did git clone) Remote repository - your git repo stored on github, bitbucket, etc. Remote - remote means server like github, bitbucket, etc. So, I decided to write these down in one place as a handy cheatsheet so that it's easier for me (and hopefully others) to recall and use.
Git switch branch and discard changes how to#
Situations like how to pull changes without committing local files, save uncommitted changes in the current branch and switch, add new changes to the last commit, reset my local branch to main, revert the latest commit from local and remote, etc. When I collaborate with others using Git, I often have to google to find the right git commands for various situations. Clean up a fork and restart it from the upstream.Revert all local changes and local commits (local).Revert last remote commit (remote, untraceable).
Git switch branch and discard changes Pc#
Revert last local commit but keep the changes in my pc.Discard all uncommitted changes (local).Copy specific commit from one branch to another.clone uncommitted changes to new branch.


