How to Git
COMMAND PROMPT
===============
pwd
- get your directory
cd
- go to that directory (follow pwd’s format)
SETUP
=======
git config
- –global
- change setting on all repos
- disclusion = only change setting on this repo
- –help
- get local help page
- user.name [“name”]
- get/set username
- (put “name” after if you want to set it)
- get/set username
- user.email [“email”]
- get/set email
- core.editor [“directory”]
- get/set default editor to type values in when prompted
- ex: core.editor “atom –wait”
git init
- creates new git repository
- first cd to the correct folder
- if you want to see it, go to file manager, options, show hidden files (roughly)
DOING STUFF
============
git status
- shows status of all files in repo
- untracked- hasn’t been anywhere yet
- unmodified- unchanged from last commit/ from after pulling
- modified- changed, but not set to commit yet
- staged- going to commit soon
git add <filename> [<filename> <filename> ...]
- add file’s content to next commit
- -start TRACKING that file, STAGE files, mark
- merge-conflicted files as RESOLVED, etc
- -start TRACKING that file, STAGE files, mark
- see names of untracked files w/ git status
- ex: git add README
- -s
- makes output shorter
- M = modified
- A = added
- ?? = not tracked
- 2 columns of symbols ^^
- left = staging area status
- right = working area status
git commit
- commits the changes in staging area (see git status)
- w/o -m
- opens core editor to type message describing commit
- close core editor window to proceed
- -m
- type commit message w/o opening core editor
- -a
- commit everything that was changed (skip staging area)
cat .gitignore <press enter> <what to ignore> <enter> <etc>
- make those files not show up in git status
-
- *.[extension] - ignore w/ that extension
- *[part of name] - ignore w/ that in end of name
- (note the * in front)
- disregards lines with # (comment)
- no .a files
- *.a
- but do track lib.a, even though you’re ignoring .a files above
- !lib.a
- only ignore the TODO file in the current directory, not subdir/TODO
- /TODO
- ignore all files in the build/ directory
- build/
- ignore doc/notes.txt, but not doc/server/arch.txt
- doc/*.txt
- ignore all .pdf files in the doc/ directory
- doc/*/.pdf
git diff <filename>
- shows difference between working directory and staging area
- ex: lines of code that were changed
-
if discluded, shows all files i think
git log
- gives list of commits w/ their message
git show <commit>
- display what changed in that commit (git log?)
-
can be HEAD => the commit you're currently on
git checkout <commit> <filename>
- restore that file in working directory to that commit’s version
git help <commandName>
- your friend. opens up local help page (html file)