Skip to content

Instantly share code, notes, and snippets.

@NISH1001
Last active December 16, 2019 08:41
Show Gist options
  • Save NISH1001/144ca54b6a246a372ee85f9a13fef937 to your computer and use it in GitHub Desktop.
Save NISH1001/144ca54b6a246a372ee85f9a13fef937 to your computer and use it in GitHub Desktop.
Rebase and Merge

Suppose there are 2 branches: master and feature

Squash Commits in Feature

  • git checkout feature
  • git rebase feature -i

This will open editor in interactive mode. DIfferent options like pick and squash are available

Rebase Feature into master without squash

First use rebase command standing in the feature branch.

  • git checkout feature
  • git rebase master

This will create a linear history, moving all the commits from Feature to current Head of master

Now go to master and merge:

  • git checkout master
  • git merge Feature

Rebase Feature into Master with Squash

  • git checkout feature
  • git rebase master -i
  • git checkout master
  • git merge feature

3-Way Merge

  • git checkout master
  • git merge feature This will create a non-linear history if master and feature have deviated with non-linearity.

Checkout File from Specific Commit

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