Git - Foundation

git clone https://github.com/gatement/demo.git

git add file1.txt
git add .
git add -A

git commit -am “”
git commit –amend -am “” (amend the previous commit comment)

git pull (pull from original repository)

git push (push to original repository)
git push [-u|--set-upstream] origin newBranch (push currnent active branch to remote, create remote branch if necessary)

git branch
git branch -a (list local and remote branches)
git branch [--list] (list local branches)
git branch -d (delete local branch)

git checkout (set active branch)
git checkout -b (create and swith to new branch)

git remote add origin https://github.com/gatement/test.git (add a remote repos reference with name “origin”)
git remote set-url origin https://github.com/gatement/test.git (set repos url to remote “origin”)

git merge (merge local active branch with local branch2)

git fetch -p (sync remote branches to local)

git tag -a -m “msg” (create a new tag locally, need to push it to remote like pushing a new branch)
git tag NewTag OldTag (rename tag OldTag to NewTag)
git tag -d TagName (delete tag TagName locally)
git push origin :refs/tags/OldName (delete tag OldName remotely)
git push --tags (sync local tags to remote)

git stash
git stash pop
git stash apply
git stash drop