# Git :::info [TOC] ::: ## What's Git? Git is a free and open source **distributed version control system** designed to handle everything from small to very large projects with speed and efficiency. ![Reference Sheet](https://i.imgur.com/wJHpJJF.png) > Expert from [NESI](https://support.nesi.org.nz/hc/en-gb/articles/360001508515-Git-Reference-Sheet) ## Git cmds... #### initialize ```shell= git init ``` #### ls/status ```shell= git status ``` #### add file ```shell= # git add <filename.extension> git add README.md ``` #### rm file ```shell= # git rm <filename.extension> git rm README.md ``` e.g: git rm helloWorld.cpp #### commit ```shell= # git commit -m "commit" git commit -m "Update" ``` #### log ```shell= git log ``` #### remote ```shell= # git remote add <remote-case> <site> git remote add origin https://github.com/{user}/hello-world.git ``` #### push **first push** ```shell= # git push -u <remote-case> <branch> git push -u origin master # git push -f/-force # # 強制push git push -f git push -force ``` > > -u = set branch & case default > **after the first push...** ```shell= git push ``` #### fetch ```shell= # git fetch <remote-case> git fetch origin ``` #### merge ```shell= # git head <older-branch> # git merge <newer-branch> git head origin git merge dev ``` #### pull (= fetch + merge) ```shell= # git pull --rebase # # 不會產生額外的 Commit 來紀錄合併這個動作 git pull --rebase ```