When I'm working with git, once in a while I found myself searching through google for proper command syntax. For those who struggle like me and for myself, I decided to maintain a command list.
If you are using git for the first time you need to setup git with your email and name.
git config --global user.email "you@example.com"
git config --global user.name "john doe"
Create a new git repository in current directory
git init
Add created repository in github as "origin" using remote repository url.
git remote add origin https://github.com/someuser/anyrepo.git
Check current status of the repository.
git status
Add modified files to commit.
git add .
git add file.ext
Commit all modified files or commit file by file with a proper commit message.
git commit -m "commit message."
git commit file.ext -m "commit message."
Push committed files to the origin from master. usually goes like push to <remote> from <master>
git push origin master
Undo your last pushed commit
git push -f origin HEAD^:master
If you need to ignore certain files or folders you need to create a .gitignore file and the folder names as bellow.
#ignore all files in node_modules.
node_modules/
#ignore .ext files.
*.ext
#but track this file, even though all .ext files are ignored
!importantFile.ext