Previous Article Next Article GIT 指令小抄
Posted in Linux

GIT 指令小抄

GIT 指令小抄 Posted on 2017 年 01 月 13 日Leave a comment

參考 nixCraftGit-Cheat-Sheet

我從圖片上截取文字下來

建立新的 repo

git init [名稱]

下載 repo

git clone [url]

查看狀態

git status

show the changes to files not yet staged

git diff

show the changes to staged files

git diff --cached

show all staged and unstaged file changes

git diff HEAD

show the changes between two commit ids

git diff commit1 commit2

list change dates and authors for a file

git blame [file]

show the file changes for a commit id and/or file

git show [commit] : [file]

show full change history

git log

show change history for file/directory including diffs

git log -p [file/directory]

list all local branches

git branch

list all branches, local and remote

git branch -av

switch to a branch, my_branch and update working directory

git checkout my_branch

建立新的 branch

git branch new_branch

刪除 branch

git branch -d my_branch

合併 branch_a 到 branch_b

git checkout branch_b
git merge branch_a

tag the current commit

git tag my_tag

commit 前將 file 弄成 staged

git add [file]

commit 前將全部 file 弄成 staged

git add .

staged 後就可以 commit 了

git commit -m '說明'

unstages file , keeping the file changes

git reset [file]

revert everything to the last commit

git reset --hard

get the latest changes from origin (no merge)

git fetch

fetch the latest changes from origin and merge

git pull

fetch the latest changes from origin and rebase

git pull --rebase

push local changes to the origin

git push

git cheat sheet

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *