git

Git Commands Mastering Basics, Merge, and Rebase

shunmare

shun

Posted on August 3, 2023

Git Commands Mastering Basics, Merge, and Rebase

Group Changes

Lists all local branches in the current repository

git branch
Enter fullscreen mode Exit fullscreen mode

Creates a new branch

git branch [branch-name]
Enter fullscreen mode Exit fullscreen mode

Switches to the specified branch and updates the working directory

git checkout [branch-name]
Enter fullscreen mode Exit fullscreen mode

Combines the specified branch’s history into the current branch.

This command is used when you want to combine changes from two different branches. It creates a new "merge commit" in the branch that preserves the history of both branches.

git merge [branch]
Enter fullscreen mode Exit fullscreen mode

Deletes the specified branch

git branch -d [branch-name]
Enter fullscreen mode Exit fullscreen mode

Rebase

The git rebase command moves or combines a sequence of commits to a new base commit. Essentially, it's a way to integrate changes from one branch into another, but it differs from merge by rewriting commit history. Use it carefully, as it can complicate the commit history and is not recommended if you're working on a public branch that others are using.

git rebase [base]
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
shunmare
shun

Posted on August 3, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related