Skip to content

Instantly share code, notes, and snippets.

@Honga1
Last active November 4, 2021 11:59
Show Gist options
  • Save Honga1/a863855bb031c5b334fe76e50d77ad00 to your computer and use it in GitHub Desktop.
Save Honga1/a863855bb031c5b334fe76e50d77ad00 to your computer and use it in GitHub Desktop.
A git rebase workflow explained
# To add a change to our repository
git checkout -b "feature/feature-name" # Creates a branch called "feature/feature-name", then checks it out, locally.
git push --set-upstream origin feature/feature-name # Publish the branch on GitHub
# Make changes to your files
git add FILENAME(S) # Adds your files to "Tracked".
git status # See your "Staged and Unstaged files (green and red respectively"
# If you're happy with these make a commit
git commit -m "Makes a commit message of less that 50 characters long"
git push # Send your commits to the remote
# When you're ready to move your changes to master, make a Pull Request on Github. Add your reviewers and wait for your change requests
# Make your change requests and push your changes to Github
# Once you have approval you can go ahead with the merge process
git checkout feature/feature-name # Switch to your feature branch
git fetch --all # Update all of your branches with any changes people have made
git pull -r # Updates your current branch with any changes someone else may have made to that branch
git rebase master # Adds any changes from master behind any of your changes. You may have to resolve conflicts here.
git push --force-with-lease # Safely adds the rebased version of your branch to Github
git checkout master # Switch to master branch
git pull # Make sure your branch is up to date
git merge --no-ff feature/feature-name # Merge your changes to your local copy of master
git push # Updates master with your new feature
# Finally delete your unused branch from GitHub
# Merge complete!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment