Clone Repository
git clone <url>Copies a remote repository to your computer.
Everyday Git commands for commits, branches and remotes. Every item below is clearly marked as a shortcut, command, or syntax reference.
git clone <url>Copies a remote repository to your computer.
git statusShows changed, staged and untracked files.
git add .Stages every changed file for the next commit.
git commit -m "message"Records staged changes with a message.
git pushUploads local commits to the remote branch.
git pullFetches and merges changes from the remote branch.
git switch <branch>Switches to an existing branch.
git switch -c <name>Creates a new branch and switches to it.
Copies a remote repository to your computer.
git clone <url>Shows changed, staged and untracked files.
git statusStages every changed file for the next commit.
git add .Records staged changes with a message.
git commit -m "message"Uploads local commits to the remote branch.
git pushFetches and merges changes from the remote branch.
git pullSwitches to an existing branch.
git switch <branch>Creates a new branch and switches to it.
git switch -c <name>Creates a new Git repository in the current folder.
git initLists local branches; the current one is marked with *.
git branchCreates a new branch at the current commit.
git branch <name>Merges another branch into the current branch.
git merge <branch>Shows the commit log for the current branch.
git logShows line-by-line changes not yet staged.
git diffRemoves the last commit but keeps its changes staged.
git reset --soft HEAD~1Temporarily shelves uncommitted changes.
git stashStages one file for the next commit.
git add <file>Replaces the last commit with staged changes and/or a new message.
git commit --amendPushes a new branch and sets it to track the remote.
git push -u origin <branch>Downloads remote changes without merging them.
git fetchDeletes a local branch that has been merged.
git branch -d <name>Shows the history one line per commit.
git log --onelineRemoves a file from the staging area but keeps your changes.
git restore --staged <file>Discards uncommitted changes to a file.
git restore <file>Reapplies the most recent stash and removes it from the list.
git stash popReapplies your commits on top of another branch.
git rebase <branch>Shows changes that are staged for the next commit.
git diff --stagedCreates a new commit that undoes an earlier commit.
git revert <commit>Lists remote repositories with their URLs.
git remote -vConnects a remote repository under a name.
git remote add origin <url>Sets the name recorded on your commits.
git config --global user.name "Your Name"Sets the email recorded on your commits.
git config --global user.email "you@example.com"Creates an annotated tag at the current commit.
git tag -a <name> -m "message"Applies a single commit from another branch.
git cherry-pick <commit>Common Git commands include Clone Repository (git clone <url>), Check Status (git status), Stage All Changes (git add .), Commit with Message (git commit -m "message"), Push to Remote (git push).
Type each command in the terminal or command-line interface used by Git.
Read its reference page and the linked documentation for prerequisites and placeholders. Check the current directory and target before running commands that change or delete data.