Skip to content

Instantly share code, notes, and snippets.

@Dor-bl
Last active December 23, 2023 09:29
Show Gist options
  • Save Dor-bl/df914b7868fbbc78581a2b763304aaee to your computer and use it in GitHub Desktop.
Save Dor-bl/df914b7868fbbc78581a2b763304aaee to your computer and use it in GitHub Desktop.
Update feat branch

Updating a feature branch First we'll update your local main branch. Go to your local project and check out the branch you want to merge into (your local main branch)

$ git checkout main

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to main will be stored in a local branch, remotes/origin/main.

$ git fetch -p origin

Merge the changes from origin/main into your local main branch. This brings your main branch in sync with the remote repository, without losing your local changes. If your local branch didn't have any unique commits, Git will instead perform a "fast-forward".

$ git merge origin/main

Check out the branch you want to merge into

$ git checkout <feature-branch>

Merge your (now updated) main branch into your feature branch to update it with the latest changes from your team.

$ git merge main

Depending on your git configuration this may open vim. Enter a commit message, save, and quit vim:

Press a to enter insert mode and append text following the current cursor position. Press the esc key to enter command mode. Type :wq to write the file to disk and quit. This only updates your local feature branch. To update it on GitHub, push your changes.

$ git push origin <feature-branch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment