This post is just a basic listing of simple git commands. These are the basics commands to start using Git, this is mostly for my own
reference. You can download git here: https://git-scm.com/. For a complete guide on git, check out https://git-scm.com/book/en/v2
Local Repo Git Commands
Command
|
Description
|
Example
|
git init
|
Used to set up a directory as a Git
|
git init
|
git status
|
Check
|
git
|
git branch
|
Creates a branch off current
|
git branch MyBranch
|
git checkout
|
Switches
|
git
|
git add
|
Adds a single for to the staging
|
git add MyFile.cpp
|
git add .
|
Adds
|
git
|
Git commit
|
Commits a change to the
|
git commit
|
git commit -m
|
Commits
|
git
|
git commit -a -m
|
Stages and Commits all change using inline
|
git commit -a -m ‘Change
|
touch
|
Creates
|
touch
|
git stash
|
Places all committed changes into a working directory
|
git stash
|
git stash apply
|
Recovers
|
Git
|
Git Ignore file can be used to exclude files from the repo. Use pattern or file name in the “.gitignore” file. I.e. *.log.
Remote Repo Git Commands
Command
|
Description
|
Example
|
git remote
|
Displays the currently available remote
|
git remote
|
git clone
|
Clones
|
git
|
git remote -v
|
Displays the repo URL
|
git remote -v
|
git fetch
|
Will
|
git
|
git pull origin
|
Will fetch and merge the changes from a remote repo
|
git pull origin
|
git push <remoterepo>
|
Pushes
|
git
|
git remote add <repoalias>
|
Creates a new local repo from a remote with an
|
git remote add myrepo
|