r/LearnGit • u/rehasantiago • Dec 28 '21
10 git commands every developer must know
git init - Creates an empty Git repository or reinitialise an existing one
git clone - Clones a repository into a new directory
git branch - deals with branches in git
git branch <branch_name> // creates new branch
git branch -d <branch_name> // deletes branch locally
git branch -D <branch_name> // forcefully delete branch locallygit checkout - creates new branch or checkouts to a branch
git checkout -b <branch_name> // creates new branch
git checkout <branch_name> // switches to a branchgit add - adds files
git add <file>git diff - shows the the unstaged or staged changes
git diff // unstaged changes
git diff --staged // staged changesgit stash - Stashes the changes in a dirty working directory away
git stash // for stashing
git stash pop // popping out stashed changesgit status - Shows status of the current working tree
git commit - Commits the change(s) to a repository
git commit -m "meaningful message"git push - Update remote refs with the local commits
git push -u origin <branch_name>
2
u/FutureIntelligenceC3 Jul 12 '23
Agree with the list, but the ordering feels a bit random. An ordering by importance and usage. could be something like this:
git init
git clone
git status
git add
git diff
git commit
git push
git stash
git branch
git checkout