git init: create new local repo
git add: add file to staging
git commit -m "commit message": commit changes to the repo
git status: tells what branch you’re currently on & changes
git clone https://github.com/maibuith/test.git: clone a repo (remote & local) into the directory you’re in
git remote add origin https://github.com/maibuith/test.git: detail the URL of the remote repo you’re gonna use for your project (need to create the remote repo first). To change: git remote set-url origin
git remote -v: list current remote repo you’re using
git push: upload committed changes to remote repo
git branch: list all available branches on repo & the branch you’re on. To create new branch: git branch <new branch name>
git checkout newBranch: move to another branch
git pull: pulls code from remote repo and combines with local repo.
git diff anotherBranch: view differences between the current branch and another. Visual tools like Meld are often used for better view.
git merge anotherBranch: merge the current branch with another. Changes are put in the current branch, not in another.
git log: list all previous commits in repo
Go back to a previous commit and force push:
$ git reset --hard <commitID> && git push --force
This will delete all the commits after that commit on GitHub.
git reset HEAD .: unstage all files