Source branch       
Destination branch  
Comments           
Date Time           
Local Path          
--------------------------------------------------

Unix style change directory

cd local_path

Before and after every set of scripts

git status

Get Latest from source_branch

git fetch origin git checkout source_branch git reset --hard origin/source_branch git pull

Get Latest from source_branch and make a dest_branch branch

git fetch origin git checkout source_branch git reset --hard origin/source_branch git pull git checkout -b dest_branch

Checkin your changes

git add . git status git commit -m "comments" git push -u

List the diff between current branch and source_branch

git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD source_branch)

Make a pull request

git config --get remote.origin.url

Merge source_branch updates into dest_branch

git fetch git checkout source_branch git pull git checkout dest_branch git pull git merge source_branch git mergetool git add . git status git commit -m "comments" git push -u

If merge gets messed up

git merge --abort

Abandon working changes

git checkout .

List local and ([a]ll including server) branches

git branch -a

Delete branch dest_branch

git branch -D dest_branch git push origin --delete dest_branch

Garbage Collection

git gc

Checkout source_branch from a commit history and make a dest_branch branch

git checkout source_branch git reset --hard head git clean -f git fetch git pull git log --graph --all git checkout _______ git checkout -b dest_branch

Checkout source_branch from date time and make a dest_branch branch

git checkout source_branch git reset --hard head git clean -f git fetch git pull git checkout `git rev-list -n 1 --before="yyyy-MM-dd HH:mm" source_branch` git checkout -b dest_branch

Merge and fully Replace dest_branch code with source_branch code

git checkout source_branch git pull git merge -s ours dest_branch git checkout dest_branch git merge source_branch git add . git status git commit -m "comments" git push -u

Clean merge temp files (CMD)

cd c:\dev del /f /s /q *.orig

Helpful

** What Files did I commit ** Get the Head SHA git rev-parse HEAD git diff --name-only [Head SHA] ** Remove file from the PR ** git checkout origin/source_branch -- [PATH]/[FILE] Branching ================================================== KEY (git log --graph --all) --[Server]-- ---Branch--- \ From / To --+-- Merge --x-- Reset | Label Label 1.1.0 Label 1.1.1 Label 1.2.0 Master-----------------------------------------------+--[INT][STAGE]-[PROD]-------------------------+--[INT][STAGE]-[PROD]--------------+--[INT][STAGE]-[PROD]----------- \ / | \ / | / | \ / | \--HotFix--[Local]--/ | / | \ / \ \ / \ \--Development-------------+---+--[DEV][QA]---------------------x------------------------+---------------------+--+--[DEV][QA]---------------------x---------------- \ / / \ / / \ \--Story--[Local]--/ / \--Story--[Local]--/ / \--Story--[Lo \ / \ / \ \--Story--[Local]--/ \--Story--[Local]-----------------------/ \--Story--[ Windows Failed Auth ================================================== Control Panel -> All Control Panel Items -> Credential Manager Windows Credentials -> Generic Credentials -> git:https://xxxxxxxxxx [Remove] Aliases ================================================== origin = remote repo master = local repo HEAD = current master committed staged = files watched sub modules = nested git repos sync = visual studio pull and push Use ================================================== new local repo git init status of repo git status add [file] to stage git add "[file]" (*.txt) . : all the files in current directory remove [file] from stage git reset "[file]" commit staged changes to master git commit -m "[comment]" -m : message list commit history git log add master to origin stage git remote add origin [remoteUrl.git] push master to stage git push -u origin master -u : remember params for next 'git push' pull changes from origin to master git pull origin master is fetch and merge diff origin to HEAD git diff HEAD diff origin to master staged git diff --staged checkout to a branch git checkout [branchTitle] -- : filePath not branchTitle -b : make branch and checkout to it view branches git branch make branch git branch [branchTitle] -d : delete branchTitle -D : force delete -a : list local and remote branches remove file from disk and stage git rm "[file]" merge from branch to current git merge [branch] from HEAD merge master to one history git rebase master list tracked repos git remote -v -v : verbose Clone a repo to a new directory git clone Manage set of tracked repos git remote prune origin git push -u Tools ================================================== gitk --all& load kitk on sub thread git log --graph console version of git flow use VS for mergetool ================================================== Add the following to your C:\Users\YOURNAME\.gitconfig file [diff] tool = vsdiffmerge [difftool] prompt = true [difftool "vsdiffmerge"] cmd = \"c:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsDiffMerge.exe\" \"$REMOTE\" \"$LOCAL\" //t keepbackup = false trustexistcode = true [merge] tool = vsdiffmerge [mergetool] prompt = true [mergetool "vsdiffmerge"] cmd = \"c:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsDiffMerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m keepbackup = false trustexistcode = true