logo

The guide to update your branch without losing code

So the goal here is to update our branch with latest changes.

Scenario

Let's say we are on the branch feature/removing-items-from-list, your branch is dirty, and we want to pull the latest changes from the develop branch.

So here, are two options:

1 . git stash

This command will basically move your current changes to another dimension.

bash
git stash                # move files to another dimension
git checkout develop     # checkout to develop branch
git pull origin develop  # pull latest changes
git checkout -           # checkout to the previous branch
git merge origin develop # merge with develop to place the changes on your branch
git stash pop            # get your changes back to continue working

2 . commit

The common process by creating a commit before merging latest changes.

bash
git commit -m "init removing items from list" # creating a commit
git checkout develop                          # checkout to develop branch
git pull origin develop                       # pull latest changes
git checkout -                                # checkout to the previous branch
git merge origin develop                      # merge with develop to place changes on your branch
0 view