Getting Started with Git - Branches and Changes
This guide covers essential Git commands for managing branches and making changes in your Git repository.
Managing Branches
-
View Current Branch: Check the current branch in your Git repository.
-
View All Branches Locally and Remote: See both local and remote branches in your repository.
-
View local branches -
git branch
: List all local branches using thegit branch
command. -
Create a new branch -
git checkout -b <new_branch> <reference_branch>
: Create a new branch and switch to it with a single command. -
Switch branches -
git checkout <branch-name>
: Switch between existing branches in your repository. -
Stash changes -
git stash
: Temporarily save your changes without committing them.
Managing Changes
-
Open Modified Files: View files with changes that haven't been committed.
-
View Side-by-Side Changes: Compare changes between two versions side by side.
-
View Inline Changes: View changes inline within the code.
-
Discard Changes: Undo modifications and revert to the last committed state.
-
Stage Changes: Prepare changes for a commit by staging them.
-
Commit: Save staged changes with a commit message.
-
Undo Commit: Undo the last commit while keeping changes in your working directory.
Aliased Commands
-
git br = git branch: Use
git br
to see available branches. -
git co = git checkout: Quickly switch to another branch with
git co
. -
git l = git log: View the commit log with
git l
. -
git st = git status: Check the Git status of your repository using
git st
. -
git po: Pull changes from the main branch into your local branch (specific usage may vary).
-
git prune-branches: Delete local branches that have been deleted on the remote server.
For more in-depth information and advanced usage, please consult the Source Control Extension Docs .