Git & Github commands
I forget a lot of things including git commands… Here is a reference I made mostly for myself or when setting people with git & github for the first time:
The usual suspects
commands often used:
git add .
add all unstaged filesgit commit -m"message here"
commit messagegit push origin featureBranch
push to remote branchgit stash
save changes not added and remove them from branchgit stash pop
puts the “saved” changes back in branch/directorygit rebase -i origin/master
usef
on commits to change tofixup
(squash)r
to reword commit messagei
to enter interactive mode in vim esc to get back to where to save and exit:wq
(enter)
First time setup
Config
git config --global user.email email@example.com
git config --global user.name first last
repo setup
git init
git add .
to add all files in directory or usegit add fileName
to add individual filesgit commit -m"initial commit"
git remote add origin github_url
git push -u origin master
.gitignore
create file in directory called .gitignore
File Contents
file_name
will not add file here to**/folderName
anything infolderName
*.fileType
anything that isfileType
Common contents in .gitignore:
.DS_Store
If you have any questions about this post or want to stay connected find me at:
Email Github Twitter LinkedIn