git使用技巧

基本操作

  1. 初級
# 全局添加基本信息
$ git config --global user.email "fizzday@yeah.net"
$ git config --global user.name "fizzday"
# 遠程倉庫:  
# 生成公鑰和私鑰
$ ssh-keygen -t rsa -C "fizzday@yeah.net"
# 拉取遠程 master 分支代碼
$ git pull origin master
# 添加所有更改到緩存區(qū)
$ git add .
# 提交更改, -m 說明注釋
$ git commit -m "這里是提交說明或注釋"
# 推送更改到遠程分支
$ git push origin master
  1. 進階
# 分支
git checkout
# 重置
git reset
# 更改
git diff
# 更改狀態(tài)
git status
  1. 升華
git tag
git branch

git更改源地址

由于使用https的git地址, 總是報錯error: The requested URL returned error: 403 Forbidden while accessing https://github.com/fizzday/fizzday.git/info/refs, 我一怒之下, 直接換了 ssh 的連接, 結(jié)果就好了, 具體操作如下

$ git remote rm origin
$ git remote add origin "git@github.com:fizzday/fizzday.git"

git標簽的使用技巧

$ git tag -a v0.1 -m “composer init″
# -a后邊的 v0.1 是標簽, -m 后邊的是說明

注意: 添加標簽要在我們 commit 之后,如:

git add .
git commit -m “fixed some bugs”
git tag -a 0.1.3 -m “Release version 0.1.3″

推送到遠程倉庫:

$ git push origin master
$ git push origin --tags
# –tags參數(shù)表示提交所有tag至服務(wù)器端,普通的git push origin master操作不會推送標簽到服務(wù)器端。

刪除標簽的命令

git tag -d v0.1

刪除遠端服務(wù)器的標簽

git push origin :refs/tags/v0.1

參考地址: http://www.cnblogs.com/tugenhua0707/p/4050072.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容