Git Commands Flashcards
Learn all the git commands
Initialize a local Git repository
git init
Create a local copy of a remote repository
git clone
Check status
git status
Add a file to the staging area
git add [file-name.txt]
Add all changes to the staging area
git add -A
Add new files and modifications, without deletions to the staging area
git add .
Commit changes
git commit -m “I am message”
Remove a file or folder
git rm -r [file-name.txt]
List branches
git branch
List all branches (local and remote)
git branch -a
Create a new branch
git branch [branch name]
Delete a branch
git branch -d [branch name]
Delete a remote branch
git push origin –delete [branch name]
Create a new branch and switch to it
git checkout -b [branch name]
Clone a remote branch and switch to it
git checkout -b [branch name] origin/[branch name]
Switch to a branch
git checkout [branch name]
Discard changes to a file
git checkout – [file-name.txt]
Merge a branch into the active branch
git merge [branch name]
Merge a branch into a target branch
git merge [source branch] [target branch]
discard changes and store them in a dirty working directory
git stash
Remove all discarded changes from the dirty working directory
git stash clear
Push a branch to your remote repository
git push origin [branch name]
Push changes to a remote repository (and remember the branDelete a remote branchch)
git push -u origin [branch name]
Push changes to a remote repository (remembered branch)
git push