Skip to content

Instantly share code, notes, and snippets.

@sheremetat
Last active April 9, 2024 12:39
Show Gist options
  • Save sheremetat/facc747b6ddb43dd0f13cdce033bf81d to your computer and use it in GitHub Desktop.
Save sheremetat/facc747b6ddb43dd0f13cdce033bf81d to your computer and use it in GitHub Desktop.
Git rebase workflow

Step 1: Checkout a new working branch from updated master

 git checkout -b <branchname>

Step 2: Make Changes

 git add
 git commit -m "description of changes"

Step 3: Sync with remote

 git checkout master
 git pull --rebase

Step 4: Update branch

 git checkout <branchname>
 git rebase master

 In case of conflicts: resolve conflict by looking at the files in question.
 git add <resolved files>
 git rebase --continue

Step 5: Squash your last N commits

 git rebase --interactive HEAD~N

Step 6: Push Changes

alternativelly create pull request and merge changes to master via UI

 git checkout master
 git merge <branchname>
 git push

Step 7: Delete working branch

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