Git Notes

Submitted by code_admin on Mon, 07/30/2018 - 13:12

Notes on my git usage

Common Commands

  1. git remote -v
  2. git branch
  1. git config --global user.name "John Doe"
  2. git config --global user.email johndoe@example.com
  3. git config --global core.editor "C:\Program Files (x86)\Notepad++/notepad++.exe"
  4. git config --list

My process

Create master repo

  1. mkdir xxx
  2. cd xxx
  3. git init --bare

Go to directory with files and make it a repo

  1. git init
  2. git add *
  3. git commit -m "Initial Version"
  4. git remote add origin xxx
  5. git config --global push.default upstream
  6. git push --set-upstream origin master
  7. git push

To make a clone

  1. git clone xxx

Tutorial: http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

Creating branch

http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-d…

Revert changes

Getting rid of local uncommited changes

  1. git stash
  2. git list
  3. git stash clear

Getting rid of local commits

  1. git reset --hard origin/master

Removing accidentally created branches

View branches

  1. git branch -a

Delete it from github.
In clones use

  1. git fetch --all --prune

Create a temp branch from a previous commit

  1. git checkout -b temp_branch 59254ed9e1e3ad4fbdd53199c87ce4e75d346bbd

Delete branch

  1. git branch -d BRANCH_NAME

Switch branch

  1. git checkout BRANCH_NAME

Display cached differences you are about to commit

  1. git diff --cached
  2. git diff **Filename**

Tags

RJM Article Type
Quick Reference