Git常用引數

2021-10-11 06:06:43 字數 1440 閱讀 8251

當你安裝完成git的時候,你需要簡單的配置一下,開啟終端:

git config --global user.name "***xx"

git config --global user.email "******@***.com"

mkdir no-temp

cd no-temp

git init

touch readme.md

git add readme.md

git commit -m "first commit"

git remote add origin 

git push -u origin master

cd existing_git_repo

git remote add origin 

git push -u origin master

第一步,你需要告訴git你的名字,這個名字會出現在你的提交記錄中。

git config --global user.name "你的名字"
然後是你的email,同樣,這個email也會出現在你的提交記錄中,請盡量保持此email和您的碼雲的註冊email一致。

git config --global user.email "你的email"
git init
git clone
git checkout -b $feature_name
git commit -am "my feature is ready"
git push origin $feature_name
git pull 《別名》 《分支名》:把遠端庫的修改拉取到本地

eg:git pull origin master

git reset --hard 簡潔/完整雜湊索引值:回到指定雜湊值所對應的版本

git reset --hard head:強制工作區、暫存區、本地庫為當前head指標所在的版本

git reset --hard head^:後退乙個版本  

tip:乙個^表示回退乙個版本

git reset --hard head~1:後退乙個版本

tip:波浪線~後面的數字表示後退幾個版本

顯示暫存區和工作區的差異

git diff
顯示暫存區和上乙個commit的差異

git diff --cached [file]

關於git的常用引數

git checkout b developgit branch 檢視當前所在分支 git checkout master 切換 git merge develop 將develop分支合併到master git push origin master 推送到遠端網頁操作 取消保護 刪除 分支重建 拉...

Git 三 常用Git命令

git config global user.name xu pengtao 全域性配置你的名字 git config global user.email 163.com 全域性配置郵箱 git config list 獲取配置資訊git status 檢視倉庫的狀態git remote add o...

Git之路 常用Git命令

git clone 使用者名稱 ip 路徑 轉殖遠端倉庫 git branch 檢視本地分支 git branch a 檢視遠端分支 git branch 分支名 切換分支 git merge 分支名 合併分支 必須先切換到你需要合併到的分支 git branch d 分支名 刪除分支 git st...