User:Atomdraco/HS-GITHUB

=GITHUB Related=

Book

 * A comprehensive treatment of Git: Pro Git
 * The book may be a dry read, but it is very thorough. Try to read at least sections 2-3 before using Git for the first time.

Man pages

 * Just type  for verbose info on that command
 * On Linux, you can also type

Printable cheat sheets

 * http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html
 * http://www.git-tower.com/blog/git-cheat-sheet/
 * https://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf
 * http://refcardz.dzone.com/refcardz/getting-started-git

Internet Quick-reference guides

 * (interactive) http://ndpsoftware.com/git-cheatsheet.html
 * (static) http://rogerdudler.github.io/git-guide/

Rebasing (and its associated dangers)

 * http://git-scm.com/book/en/Git-Branching-Rebasing
 * http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/

Internet Tutorials

 * (interactive) http://pcottle.github.io/learnGitBranching/index.html
 * (interactive) https://try.github.io
 * http://rogerdudler.github.io/git-guide/

Extral Online Links

 * Git Homepage
 * An introduction to git-svn for Subversion/SVK users and deserters
 * A port of TortoiseSVN to TortoiseGit.
 * Integrate Git with Windows Explorer and Visual Studio
 * Git on Windows: Whence Cometh Configuration - Good article that describes where on Windows the gitconfig is stored based on system/global/local
 * Oh s***, git! - While a NSFW named site, it has very helpful advice on common problems you can run in to with git and how to fix the problem
 * Git Merge Strategy Options and Examples from Atlassian

MISC

 * Git branching model: A successful Git branching model
 * Pro Git book online version)
 * + Undoing Things in Git


 * Git Tutorial
 * Other info:
 * - git reset vs revert
 * - git merge vs rebase
 * - An introduction to Git merge and rebase

A Quick Glance of Some Git Commands
git help   #in git bash prompt will bring up command manual gitk                 #graphical history viewer git fetch            #find out the changes done in the remote repo/branch git diff ...origin   #use this along with git fetch to see diff git status [-s|--short]   #simplified output, ??-untracked, A-added to staging, M-modified git blame git difftool git mergetool git diff git diff git show git diff --staged git diff git lol   #or lola git lol --simplify-by-decoration git log --   #history git log --graph --pretty=oneline --abbrev-commit   #visual view of branches git log --graph --pretty=oneline --abbrev-commit --simplify-by-decoration git branch --all git branch -a --no-merged   #list all branches not been merged into branchname git branch -d   #delete a local branch git checkout git checkout -b|-B  [ ]   #use the "start point" to specify off which branch git add --       #stage a file git restore --staged   #to unstage a staged file git commit git merge git merge --squash git mv git rm git stash push        #can omit push git stash show git stash list git stash pop git clean -xdf

An Example of .gitconfig With Aliases
[diff] tool = bc4 [difftool] prompt = false [difftool "bc4"] trustExitCode = true cmd = "'/C/Program Files/Beyond Compare 4/bcomp'" \"$LOCAL\" \"$REMOTE\" [merge] tool = bc4 [mergetool] prompt = false [mergetool "bc4"] trustExitCode = true cmd = "'/C/Program Files/Beyond Compare 4/bcomp'" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\" [user] email = hattie.stamer@ngc.com [core] editor = vim [alias] ec  = config --global -e st  = status sst = status -s last = log -1 HEAD k   = !gitk & ka  = !gitk --all & iclean = clean -xdf co = checkout cof = checkout --                                 #unmodify a file new  = !sh -c 'git log $1@{1}..$1@{0} "$@"' up   = !git pull --rebase --prune $@ && git submodule update --init --recursive  #pull changes from remote & rebase & clean unused branches cob  = checkout -b                                #start new branch based on ... cm   = !git add -A && git commit -m               #commit regularly save = !git add -A && git commit -m 'SAVEPOINT'   #add all changes including untracked files and creates a commit wip  = commit -am "WIP"                           #only commits tracked changes undo = reset HEAD~1 --mixed                       #resets the previous commit, keeps all the changes from that commit #amend = commit -a --amend                         #merely need to modify the previous commit...   amend = commit --amend                          #merely need to modify the previous commit... wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard  #commit then remove commit bclean = "!f { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"  #used by "bdone" - do this from master branch, cleanup of merged branches

GUI
Git comes with built-in GUI tools for committing (git-gui) and browsing (gitk), but there are several third-party tools for users looking for platform-specific experience.

Any GUI can be used. If you'd like a different GUI than what's listed below, feel free to find your own.

Git Extensions

 * 1) Follow the above instructions to install Git for Windows
 * 2) Install steps:
 * 3) * Presuming you did step #1 above, there's no need to install MsysGit
 * 4) * Presuming you intend to use Beyond Compare, there's no need to install KDiff3
 * 5) * Choose the "PuTTY (plink.exe)" option
 * 6) ** Beware that GitExtensions installs its own Putty files into its install directory and will use those by default in the settings. Make sure you change the path settings to point to any *existing* install location of Putty if you expect pageant and plink to work properly. If you don't do this then you will get vague server errors when attempting to clone repositories.
 * 7) Run Git Extensions
 * 8) * Configure a username and email address (please use your real info)
 * 9) * In Settings --> Global Settings, select "BeyondCompare3" as the Mergetool
 * 10) * In Settings --> Global Settings, select "beyondcompare3" as the Dergetool
 * 11) * In Settings, verify that the "Checklist" is all green.
 * 12) * In Settings --> Appearance, un-check "Get author image from gravatar.com"
 * 13) * In Settings --> Plugins --> Check for updates, set Enabled to "false"

SourceTree

 * 1) Follow the above instructions to install Git for Windows
 * 2) Install .NET 4.5
 * 3) Launch SourceTree.  When prompted:
 * 4) * Select "I don't want to use Mercurial"
 * 5) * Enter your full name and email address. Agree and click Next.
 * 6) * Select "Use PuTTY" and click Next.
 * 7) * If asked to import an SSH key, click No.
 * 8) * Click Finish.
 * 9) * When it tries to test your non-existent connections, click Skip Test.

TortoiseGit
Now you'll have access to 90% of everything you need to use Git from a right-click context menu. Additionally, Tortoise Git will highlight items in Windows Explorer that are Git repositories.
 * 1) Follow the above instructions to install Git for Windows
 * 2) Choose plink as your shell tool
 * 3) Click through and complete the install
 * 4) Bring up task manager
 * 5) Kill and restart explorer.exe
 * 6) Right click and go to "TortoiseGit->Settings"
 * 7) * Under General
 * 8) * Git.exe path browse to "C:\Program Files\Git\bin"
 * 9) * Click check version to make sure it's right
 * 10) Save your changes

How to create a branch off a specific commit
git log              # use this to check commit id info, etc. git checkout  git branch 

How to check difference in remote code without copying to local
git fetch git diff ...origin

How to delete local & remote branch
git branch -d             #delete a local branch git push origin --delete  #delete a remote branch was pushed

How to change comments for last commit

 * It can only be used to fix the very last commit. Older commits can't be modified with "amend".
 * You should never "amend" a commit that has already been published / pushed to a remote repository! This is because "amend" effectively produces a completely new commit object in the background that replaces the old one. If you're the only person who had this commit, doing this is safe. However, after publishing the original commit on a remote, other people might already have based new work on this commit. Replacing it with an amended version will cause problems.

git add xxx/xxx/file.xx                             #If you have more changes to add git commit --amend -m "This is the correct message" #Change comments, also add more changes

How to undo the last commit
git log [--oneline] [--graph] #Get commit history list git reset --soft HEAD~1       #Rewind current HEAD branch to the specified revision, #   (preserve changes done to files) git reset --hard HEAD~1       #Rewind without keeping changes git reset --soft/hard
 * git reset is like the opposite of the git add
 * Use git log  to see previous commits
 * [Link to article]