

Well first of all git fetch downloads the latest from remote without trying to merge or rebase anything. OR If you are on any other branch you can use the branch name like below: git reset -hard origin/ How does all this work? Then, if you are on the “master” branch you can do the following: git reset -hard origin/master WARNING: If you have any local commits or uncommitted changes, they will be gone by doing this!įirst you start with a “fetch - all” like the following git fetch -all Then the checkout command will update the working tree with the particular file from the downloaded changes (origin/master). git checkout origin/master - path/to/file. In review, our remote repository now contains: A modified README.md on the development branch A master branch that is ahead one commit Now, let’s modify our README. During the process of working on a shared git repository, coworkers might need access to one another’s branches.
#GIT CHECKOUT MASTER HOW TO#
Well, one way is to delete the repo and clone again but the problem with this is, you will also lose any untracked files that exists in your git repo folder! So here is what you can do about it: The git fetch command will download all the recent changes, but it will not put it in your current checked out code (working area). The git checkout command lets us switch to the master branch. How to Checkout to a Branch in Multiple Remotes. git directory inside it, pull down all the data for that.

Has it happened to you that you have a really old git repository, that is not in sync with the remote repository and you also may or may not have some local commits, but now you want to “pull” remote changes and don’t care about your local changes? The command above, not only creates a directory named mediumgit but it will also initialise a.
