

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? Execute command git fetch & git rebase origin/master.

Then, if you are on the “master” branch you can do the following: git reset -hard origin/master Navigate to the root directory of your project where you want to perform rebase. src/myproject (branch2) git rebase master Any changes in contains that are already in master will be 'swallowed' into those master changes, and you'll remain with just the distinct changes this branch contains. git checkout login-page Check out the login-page branch 2. Checkout feature branch Make sure to be in the feature branch that you want to rebase. 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 These are the steps to rebase a branch in Git. 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: 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?
