๐๐ข๐ญ ๐๐ซ๐๐ง๐๐ก ๐๐จ๐ฆ๐ฆ๐๐ง๐
The ๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก
command in Git is used for managing branches within a repository. It provides various functionalities to create, list, delete, and manipulate branches. Below are some common use cases for the ๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก
command:
๐ ๐๐ซ๐๐๐ญ๐ ๐ ๐๐๐ฐ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Creates a new branch with the specified name.
`๐ ๐ข๐ญ ๐๐ก๐๐๐ค๐จ๐ฎ๐ญ -๐ <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Creates and switches to a new branch in one command.
๐ ๐๐ฐ๐ข๐ญ๐๐ก ๐๐ซ๐๐ง๐๐ก๐๐ฌ
`๐ ๐ข๐ญ ๐๐ก๐๐๐ค๐จ๐ฎ๐ญ <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Switches to the specified branch.
`๐ ๐ข๐ญ ๐ฌ๐ฐ๐ข๐ญ๐๐ก <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Switches to the specified branch (Git version 2.23 and later).
๐ ๐๐๐ซ๐ ๐ ๐๐ซ๐๐ง๐๐ก๐๐ฌ
`๐ ๐ข๐ญ ๐ฆ๐๐ซ๐ ๐ <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Merges changes from the specified branch into the current branch.
๐ ๐๐ข๐ฌ๐ญ ๐๐ซ๐๐ง๐๐ก๐๐ฌ
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก` Lists all the branches in the repository. The current branch is highlighted with an asterisk (`*`).
๐ ๐๐ซ๐๐๐ญ๐ ๐๐ง๐ ๐๐ฐ๐ข๐ญ๐๐ก ๐ญ๐จ ๐ ๐๐๐ฐ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ก๐๐๐ค๐จ๐ฎ๐ญ -๐ <๐ง๐๐ฐ_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Creates a new branch with the specified name and switches to it in a single command. (Or, using ๐ ๐ข๐ญ ๐ฌ๐ฐ๐ข๐ญ๐๐ก -๐ <๐ง๐๐ฐ_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>
in Git versions 2.23 and later.)
๐ ๐๐๐ง๐๐ฆ๐ ๐ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ฆ <๐ง๐๐ฐ_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐> Rename the current branch.
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ฆ <๐จ๐ฅ๐_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐> <๐ง๐๐ฐ_๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Rename a specific branch.
๐ ๐๐๐ฅ๐๐ญ๐ ๐ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Deletes the specified branch. The -๐
option ensures that the branch has been fully merged before deletion. If the branch contains unmerged changes, Git will prevent deletion.
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ <๐๐ซ๐๐ง๐๐ก_๐ง๐๐ฆ๐>` Forces deletion of the specified branch, even if it contains unmerged changes.
๐ ๐๐ข๐๐ฐ ๐๐๐ฆ๐จ๐ญ๐ ๐๐ซ๐๐ง๐๐ก๐๐ฌ
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ซ` Lists remote branches (branches on the remote repository).
๐ ๐๐ข๐๐ฐ ๐๐ฅ๐ฅ ๐๐ซ๐๐ง๐๐ก๐๐ฌ (๐๐จ๐๐๐ฅ ๐๐ง๐ ๐๐๐ฆ๐จ๐ญ๐)
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐` Lists both local and remote branches.
๐ ๐๐ก๐จ๐ฐ ๐๐ฎ๐ซ๐ซ๐๐ง๐ญ ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก โ ๐ฌ๐ก๐จ๐ฐ-๐๐ฎ๐ซ๐ซ๐๐ง๐ญ` Displays the name of the currently checked-out branch.
๐ ๐๐ข๐๐ฐ ๐ญ๐ก๐ ๐๐๐ฌ๐ญ ๐๐จ๐ฆ๐ฆ๐ข๐ญ ๐จ๐ง ๐๐๐๐ก ๐๐ซ๐๐ง๐๐ก
`๐ ๐ข๐ญ ๐๐ซ๐๐ง๐๐ก -๐ฏ` Shows the last commit on each branch along with the commit message.