Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active August 21, 2020 07:57
Show Gist options
  • Save abelcallejo/a7f35d9277417560b4c5a7178f8677d1 to your computer and use it in GitHub Desktop.
Save abelcallejo/a7f35d9277417560b4c5a7178f8677d1 to your computer and use it in GitHub Desktop.
Pushing changes without fucking the master branch

Updating your master branch

git checkout master
git pull

Pushing changes without fucking the master branch

Create a branch

git branch mybranch

Select the newly created branch

git checkout mybranch
git branch -v

Make changes

Stage the files you need to push

git add *
git commit -m "concise description of that changes"
git branch -v
git checkout master
git pull
git branch -v
git checkout mybranch
git rebase master
git push -u origin mybranch

Use the GitHub feature of merging a pull request to merge branch called mybranch to master

Best practices

  1. Once merged the feature branch into the master branch, delete the feature branch remotely and locally.
  2. Always use a different branch, not the master branch
  3. Use git rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment