Git branching fundamentals
Unproofread notes
Viewing Branches
git branch # List local branches
git branch -a # List all branches (local and remote)
Creating Branches
git branch <branch-name> # Create a new branch (stays on current branch)
git checkout -b <branch-name> # Create and switch to new branch in one command
Switching Branches
git checkout <branch-name> # Switch to an existing branch
Merging Branches
git checkout main # Switch to the target branch
git merge <branch-name> # Merge specified branch into current branch
Deleting Branches
git branch -d <branch-name> # Delete a branch (safe - won't delete unmerged)
git branch -D <branch-name> # Force delete a branch (even if unmerged)
Remote Branch Operations
git push origin <branch-name> # Push branch to remote
git pull origin <branch-name> # Pull remote branch
- ← Previous
AI coding is hard - Next →
Art evolves
Comment via email