Git使用命令整理

2021-07-03 18:38:52 字數 3168 閱讀 7036

githuo靜態頁面

github知識積累部落格貢獻頁面

git config --global user.name "your name"

git config --global user.email "your email"

git init

git add

git commit -m 'comment'

git

status

gitdiff

gitdiff

head--

filename

檢視工作區和版本庫里最新版本的區別

git

log-

-pretty=oneline

顯示提交日誌,不包括被回退

gitreflog

顯示提交歷史

gitlog--

graph--

pretty=oneline--

abbrev

-commit

檢視分支情況

git

reset--

hard

head^

head表示當前版本,head^^表示前2各版本

head~100表示前100各版本

gitreset--

hard

commit_id

回退到特定版本

git checkout --filename

撤銷修改,如果暫存區沒有該檔案就從版本庫提取檔案

git reset head filename

可以撤銷暫存區的修改

從版本庫刪除

git rm filename

git commit -m 'delete filename'

從版本庫恢復

git

checkout--

filename

ssh-keygen -t rsa -c '[email protected]'生成ssh key

ssh -t [email protected]測試ssh key新增成功

git remote add origin git_url關聯遠端庫

git clone git_url轉殖遠端倉庫

git push -u origin master

-u 在遠端和本地分支間建立聯絡,第一次建立即可

git checkout -b dev origin/dev通過遠端分支建立本地分支

git branch --set-upstream dev origin/dev建立本地分支與遠端分支的聯絡

git checkout -b dev建立並切換分支

git branch dev

git checkout dev

git branch -d刪除分支

git branch -d刪除未合併分支

git merge dev合併dev 到當前分支

git merge --no-ff -m 'merge with no-ff' dev合併時禁用 fast forward

git stash 儲存並清空工作區

git stash list 列出被儲存的工作區

git stash drop 刪除儲存的工作區

git stash pop 彈出儲存的工作區

修復bug:建立bug分支,修復再合併。當現場有工作時,可以使用 git stash 儲存

git tag用於新建乙個標籤,預設為head,也可以指定乙個commit id

git tag -a -m "introduce"指定標籤資訊

git tag -s -m "introduce"pgp簽名

git tag檢視所有標籤

git show tagname顯示標籤詳細資訊

git tag -d v0.1刪除標籤

git push origin推送標籤到遠端

git push origin --tags推送所有標籤到遠端

git tag -d v0.9先刪除本地標籤

git push origin :refs/tags/v0.9刪除遠端分支

git config --global color.ui true

github ignore

忽略檔案原則:

- 自動生成檔案

- 中介軟體

- 敏感資訊

git config --global

alias.st status

git config --global

alias.co checkout

git config --global

alias.ci commit

git config --global

alias.br branch

git config --global

alias.unstage 'reset head'

git config --global

alias.last 'log -1'

git config --global

alias.lg "log --color --graph --pretty=format:'%cred%h%creset -%c(yellow)%d%creset %s %cgreen(%cr) %c(bold blue)<%an>%creset' --abbrev-commit"

global 配置檔案 ~/.gitconfig

Git使用命令整理

為什麼80 的碼農都做不了架構師?githuo靜態頁面 github知識積累部落格貢獻頁面 git config global user.name your name git config global user.email your email git init git add git commi...

GIT基本使用命令整理

首先感謝 給了乙個很簡單明瞭的教程。這篇文章只是為了方便自己以後使用的時候怕忘記了什麼而進行整理的。並沒有詳細的介紹。需要學習的朋友建議移步 謝謝。第一步,建立版本庫 在當前的目錄下,執行git bash。然後輸入git init 來建立.git 用來跟蹤管理 git倉庫。建立git 後,這是乙個空...

使用git命令匯出專案 git使用命令整理

什麼是版本庫呢?版本庫又名倉庫,英文名repository,你可以簡單理解成乙個目錄,這個目錄裡面的所有檔案都可以被git管理起來,每個檔案的修改 刪除,git都能跟蹤,以便任何時刻都可以追蹤歷史,或者在將來某個時刻可以 還原 所以,建立乙個版本庫非常簡單,首先,選擇乙個合適的地方,建立乙個空目錄 ...