A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Task | Command / Reference URL | Notes | |||||||||||||||||
2 | Getting started with Git | http://www.youtube.com/watch?v=ZDR433b0HJY | ||||||||||||||||||
3 | ||||||||||||||||||||
4 | Further Reading | |||||||||||||||||||
5 | Line endings ^M issues | http://stackoverflow.com/questions/1889559/git-diff-to-ignore-m | ||||||||||||||||||
6 | ||||||||||||||||||||
7 | Installing & Configuring on Ubuntu | |||||||||||||||||||
8 | Install git on an ubuntu system | apt-get install git | ||||||||||||||||||
9 | Specify your name after git is installed | git config --global user.name "Jared De Blander" | ||||||||||||||||||
10 | Specify your email after git is installed | git config --global user.email jared0x90@gmail.com | ||||||||||||||||||
11 | Auto unix line endings | git config --global core.autocrlf true | ||||||||||||||||||
12 | Enable colored output | git config --global color.ui true | ||||||||||||||||||
13 | Cache password for some time | git config --global credential.helper cache | ||||||||||||||||||
14 | Location of your git config file | ~/.gitconfig | ||||||||||||||||||
15 | Shortcut to edit your global .gitconfig | git config --global -e | ||||||||||||||||||
16 | My basic ~/.gitconfig | https://github.com/jwd83/dotfiles | ||||||||||||||||||
17 | ||||||||||||||||||||
18 | Working with Git | |||||||||||||||||||
19 | Start a new project in the current folder | git init | ||||||||||||||||||
20 | View your current branch and pending commits | git status | ||||||||||||||||||
21 | Add the current tree of files to the next commit | git add . | Files matching those in .gitignore will not be included in the next commit. See the .gitignore section | |||||||||||||||||
22 | Perform a diff compared to the prior snapshot | git diff | ||||||||||||||||||
23 | Perform a diff compared to the prior snapshot and use color | git diff --color | You can turn on colors by default in your ~/.gitconfig file | |||||||||||||||||
24 | Show diff of yellow from common ancestor to the HEAD that will be merged | git diff ...yellow | Note the 3 dots | |||||||||||||||||
25 | Show list of files from yellow to common ancestor to the HEAD that will be merged | git diff --name-status ...yellow | Note the 3 dots | |||||||||||||||||
26 | Commit the currently added files with a commit message | git commit -m 'your message' | ||||||||||||||||||
27 | Commit any modified files that are in the current snapshot | git commit -a -m 'your message' | ||||||||||||||||||
28 | Clear out the pending commit from git adds | git reset HEAD | If this fails read the failure message and see what else you need to do. you may need to force a reset if it involved file deletion | |||||||||||||||||
29 | Reset/revert ALL changes to a working copy | git reset --hard | This will reset all changes in your working copy | |||||||||||||||||
30 | Undo most recent commit on current branch. | git reset --hard HEAD~1 | This will wipe out the prior version completely including history, modifications, etc | |||||||||||||||||
31 | Remove a file from the repo on the next commit | git rm 'somefile.ext' | ||||||||||||||||||
32 | View the snapshot log | git log | ||||||||||||||||||
33 | Show commits in yellow that would be merged into current branch | git log ..yellow | Note the 2 dots. | |||||||||||||||||
34 | Search your current branch for a case sensitive text pattern such as blue | git grep blue | ||||||||||||||||||
35 | Search your current branch for a case insensitive text pattern such as bLuE | git grep -i bLuE | ||||||||||||||||||
36 | View the list of your local branches and your current branch | git branch | ||||||||||||||||||
37 | View the list of all local and remote branches you have | git branch -a | ||||||||||||||||||
38 | View the list of all remote branches | git branch -r | ||||||||||||||||||
39 | Create a new branch called blue from current snapshot and switch to it | git checkout -b blue | ||||||||||||||||||
40 | Create a new bracnh called yellow from current snapshot but don't switch to it | git branch yellow | Generally git checkout -b will be simpler as you typically want to switch to your new branch | |||||||||||||||||
41 | Switch to your master branch snapshot | git checkout master | ||||||||||||||||||
42 | Switch to your branch blue | git checkout blue | ||||||||||||||||||
43 | Switch to a remote branch to preview | git checkout origin/somebranch | You shouldn't really make changes here. This puts you in detatched head state. More of a read-only view. Create your own local branch | |||||||||||||||||
44 | Switch to a remote branch and then branch it for yourself | git checkout origin/somebranch; git checkout -b your_new_branch | This is a 2 step process. | |||||||||||||||||
45 | Merge branch blue into your currnet branch | git merge blue | ||||||||||||||||||
46 | Dealing with merge conflicts | http://www.youtube.com/watch?v=ZDR433b0HJY?t=52m50s | ||||||||||||||||||
47 | Delete a branch called yellow | git branch -d yellow | Lowercase -d is safe delete. Will not delete unique data. Uppercase -D is a forced delete | |||||||||||||||||
48 | Delete a remote branched called yellow | git push origin --delete yellow | ||||||||||||||||||
49 | Delete a remote branched called yellow (shorthand) | git push origin :yellow | Notice the colon ( : ) before yellow | |||||||||||||||||
50 | Remove your local copies of remote branches that are no longer in use from a remote named origin | git remote prune origin | ||||||||||||||||||
51 | Ignore further changes to a tracked file (helpful for modifying config/settings files) | git update-index --assume-unchanged <file> | ||||||||||||||||||
52 | Undo ignore further changes to a tracked file | git update-index --no-assume-unchanged <file> | ||||||||||||||||||
53 | Recursive add a file extension from the current directory | git add ./\*.js | Specify a subdirectory by replacing ./ with the folderName/ | |||||||||||||||||
54 | ||||||||||||||||||||
55 | Working with Git Remotes | |||||||||||||||||||
56 | Adding a remote named origin | git remote add origin https://some.thing.com/yourfiles-git.git | ||||||||||||||||||
57 | ||||||||||||||||||||
58 | Managing the .gitignore file | |||||||||||||||||||
59 | ||||||||||||||||||||
60 | ||||||||||||||||||||
61 | ||||||||||||||||||||
62 | ||||||||||||||||||||
63 | ||||||||||||||||||||
64 | ||||||||||||||||||||
65 | ||||||||||||||||||||
66 | ||||||||||||||||||||
67 | ||||||||||||||||||||
68 | ||||||||||||||||||||
69 | ||||||||||||||||||||
70 | ||||||||||||||||||||
71 | ||||||||||||||||||||
72 | ||||||||||||||||||||
73 | ||||||||||||||||||||
74 | ||||||||||||||||||||
75 | ||||||||||||||||||||
76 | ||||||||||||||||||||
77 | ||||||||||||||||||||
78 | ||||||||||||||||||||
79 | ||||||||||||||||||||
80 | ||||||||||||||||||||
81 | ||||||||||||||||||||
82 | ||||||||||||||||||||
83 | ||||||||||||||||||||
84 | ||||||||||||||||||||
85 | ||||||||||||||||||||
86 | ||||||||||||||||||||
87 | ||||||||||||||||||||
88 | ||||||||||||||||||||
89 | ||||||||||||||||||||
90 | ||||||||||||||||||||
91 | ||||||||||||||||||||
92 | ||||||||||||||||||||
93 | ||||||||||||||||||||
94 | ||||||||||||||||||||
95 | ||||||||||||||||||||
96 | ||||||||||||||||||||
97 | ||||||||||||||||||||
98 | ||||||||||||||||||||
99 | ||||||||||||||||||||
100 |