Skip to content

Instantly share code, notes, and snippets.

@santisbon
Last active March 21, 2024 15:50
Show Gist options
  • Save santisbon/a1a60db1fb8eecd1beeacd986ae5d3ca to your computer and use it in GitHub Desktop.
Save santisbon/a1a60db1fb8eecd1beeacd986ae5d3ca to your computer and use it in GitHub Desktop.
Deploying from #Git branches adds flexibility. Bring your feature branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

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

$ git checkout master

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 master will be stored in a local branch, remotes/origin/master.

$ git fetch -p origin

Merge the changes from origin/master into your local master branch. This brings your master 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/master

Check out the branch you want to merge into

$ git checkout <feature-branch>

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

$ git merge master

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

  1. Press a to enter insert mode and append text following the current cursor position.
  2. Press the esc key to enter command mode.
  3. 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>
@ana-moga
Copy link

ana-moga commented Mar 4, 2020

Thank you, this helped me a lot today.

@EmKaCe
Copy link

EmKaCe commented Apr 2, 2020

Great guide, solved my issue, thanks!

@timsully
Copy link

timsully commented Jun 9, 2020

This is amazing, thank you so much!

@smw7156
Copy link

smw7156 commented Jun 25, 2020

During "git merge master" step,
I got conflict. I resolved the conflict by editing the files.
After that, How do i restart the merge process?

you need to git add <file> and then commit.
It will create a new merge commit. Completing you merge process

@radhikaRadz
Copy link

Really helped me. Thanks a lot.

@frednjoro7
Copy link

Thanks !

@toba-madamori
Copy link

This helped, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment