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 featureBranchpush to remote branchgit stashsave changes not added and remove them from branchgit stash popputs the “saved” changes back in branch/directorygit rebase -i origin/masterusefon commits to change tofixup(squash)rto reword commit messageito 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.comgit config --global user.name first last
repo setup
git initgit add .to add all files in directory or usegit add fileNameto add individual filesgit commit -m"initial commit"git remote add origin github_urlgit push -u origin master
.gitignore
create file in directory called .gitignore
File Contents
file_namewill not add file here to**/folderNameanything infolderName*.fileTypeanything 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