PageRenderTime 30ms CodeModel.GetById 23ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/workbook/markdown/08-Everyday-Commands.md

http://github.com/matthewmccullough/git-workshop
Markdown | 84 lines | 47 code | 37 blank | 0 comment | 0 complexity | f48827a4499238e45bb7b61c1f752c2c MD5 | raw file
 1# Everyday Commands
 2
 3## Status
 4Shows the current status of tracked objects in a repo while sitting anywhere in that repo's directory tree).
 5
 6    git status
 7
 8Everything unstaged diffed to the last commit
 9
10    git diff
11    
12Everything staged diffed to the last commit
13
14    git diff --cached
15    
16Everything unstaged and staged diffed to the last commit
17
18    git diff HEAD
19
20## Adding
21    git add <WILDCARD>
22    git add <SPECIFICFILENAME>
23
24Interactive
25
26    git add -i
27
28Interactive patch mode
29
30    git add --patch
31    git add -p
32    
33## Removing
34Remove a file from being tracked
35
36    git rm FILENAME
37    
38## Renaming (Moving)
39Rename a tracked file
40
41    git mv FILENAME NEWFILENAME
42
43## Committing
44Commit changes with a message provided interactively ($GIT_EDITOR or $EDITOR)
45
46    git commit
47    
48Or preview what would have occurred
49
50    git commit --dry-run
51
52Commit with a message provided on the CLI
53
54    git commit -m'Some message'
55
56Commit and add any modified tracked files in one unified command
57
58    git commit -a
59
60## Git Ignores
61Stored in a file at any level of the tree.
62
63    .gitignore
64
65Can apply recursively.
66
67    **/*.tmp
68
69Glob pattern format
70
71    **/log*/*.log
72
73Exclusions
74
75    !logstuffweneedtokeep
76    
77## Checkout to a different Branch
78Switch to a given branch
79
80    git checkout BRANCHNAME
81
82Switch to a detached (arbitrary, detached) HEAD
83
84    git checkout TREEISH