Simple git reference for when I forget.
git init
- create a new repogit clone <repo url> <folder name>
- download a project to a custom foldergit status
- check repo status
git log
- display commit ID (SHA), author, date, and commit messagej
(up),k
(down),q
(exit) - scrolling through commit historygit log --stat
- view modified filesgit log -p
orgit diff
- view file changes in commitgit log -p --stat
- view both modified files and file chanegsgit show <SHA id>
- view file changes of specific SHA idgit show SHAid --state
- view modified files of specific SHAgit log --stat <SHA id>
- view specific commit by ID
git add .
- add all files in current directory to stagegit add <file names with space as delimiter>
- add specific files to stagegit add -u
- add all tracked files
git commit -m <message>
- write a commit message without using the text editor- Guideline: https://udacity.github.io/git-styleguide/
git commit
- write commit message with text editor openedgit commit -a
- directly add files to the repo without going through staging
- Note: Assumes that VSCode is installed.
- Run
touch .gitignore
to create a file - Run
code .gitignore
to open and edit
- Run
New-Item .gitignore -type file
to create a file - Run
code .gitignore
to open and edit
- Run
copy NUL .gitignore
to create a file - Run
code .gitignore
to open and edit
git tag
- check version of tag in command linegit tag -a <tag name>
- write a message for a specific version of the filegit log --decorate
- show the current branch and tag version- `git tag -d - delete tag version
git tag -a <tag name> <SHA id>
- add a tag for a specific commit by SHA id.
git branch
- show current branchgit branch <branch name>
- create a new branchgit checkout <existing branch name>
- switch to another branchgit log --oneline --decorate
- display current active branch with SHA id and commits onlygit branch -d <branch name>
- delete branch by namegit checkout -b <branch name>
- create new branch and switch to itgit checkout -b <branch name> master
- create a new branch in the same location as the master branch and switch to itgit log --oneline --decorate --graph --all
- display all branches in folder
git reset --hard HEAD^
- undo branch mergegit merge <branch name>
- merge branch by name
git commit --amend
- correct commit details in branchgit revert <SHA id>
- revert changes up to commit specified by id
git remote add origin <repo url>
- add a remote url for the repositorygit remote set-url origin <repo url>
- set a specific url for the repositorygit remote -v
- check the push and pull locations