參考 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

Related posts 相關文章
記得把網站下的 .git 目錄封鎖,不然會被看到
More...
gitlab-ce 升級到 17.0.0 後續
More...
gitlab-ce 升級到 17.0.0 就壞掉了
More...
最近要小心 GitHub 上的 POC 庫,可能是惡意程式
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。