Exploring Key Features of Git Branching

GIT REBASE

  • GIT Rebase is used to keep current branch in sync with target branch.

  • Git Rebase is used to maintain the Linear Commit History in the Target Branch.

  • As a best practice, it is always recommended to used rebase before merge action.

  • With this, we can prevent merge conflicts in the target branch.

  • git merge --squash

    • It used the combine more than one commits into single commit point

    • git merge --squash <branch_name>

    • git commit -m "<Commit_Message>"

GIT Stash

  • git stash save "message" - Create an entry in stash list

  • git stash list - View the stash list Entries

  • git stash apply

    • Apply the latest entry back to the staging area

    • That latest entry will not be deleted from stash list

    • git stash apply stash@{2}

      • Apply a specific entry back to staging area.

      • That entry will not be deleted from the stash list.

  • git stash drop

    • Drop/Delete the latest entry from the stash list.

    • git stash drop stash@{2}

      • Drop/Delete a specific entry from the stash list.

  • git stash pop

    • Apply the latest entry back to staging area and delete that entry from stash list.

    • git stash pop stash@{2}

      • Apply a specific entry back to staging area and delete that entry from stash list.

  • git stash clear - Clean-up the Stash List.