基本操作
- 初級
# 全局添加基本信息
$ 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
- 進階
# 分支
git checkout
# 重置
git reset
# 更改
git diff
# 更改狀態(tài)
git status
- 升華
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