1.初始化git
? git init
? 2.查詢狀態(tài)
? git status
? 3.添加文件4
? ? git add .代表提供全部 注:不建議使用
? 4.git config --list 查看配置
? 5.git commit -m "注解"
查詢?nèi)罩?/p>
git log --pretty=oneline
代碼版本管理
? 歷史回退(commit回退):git reset --hard commit_id
? 放棄當前工作區(qū)的修改:git checkout -- 文件路徑
? 暫存區(qū)回退到工作區(qū):git reset HEAD 文件路徑
將本地代碼推送到遠程倉庫:
? ? 1.本地配置
? ? ? (1)配置郵箱和用戶名?
? ? ? ? ? ? ? git config --global user.email "郵箱名"
? ? ? ? ? ? ? git config --global user.name "郵箱名"
? ? ? ? 本地生成公鑰和密鑰對
? ? ? ? ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
? ? 2.遠程配置
? ? ? setting-ssh and gpg keys->new ssh key
? 測試是否連通
ssh -T git@github.com
? ? 3.再推送
? ? ? 連接遠程
添加遠程
git remote add origin 遠程倉庫地址
# 刪除
git remote remove origin
git pull 失敗 :
git pull origin master --allow-unrelated-histories
? ? ? 再推送:git push
git add .
? git commit
? git push
一、 分支:方便團隊協(xié)作開發(fā)的利器
? 通常有的分支:master
? 開發(fā)分支:dev
? 調(diào)試 bug:bugfix
? 新功能: feature
二拇勃、分支命令
? 查看:git branch
? 創(chuàng)建分支:git branch 分支名
? 切換分支:git checkout 分支名
? 即創(chuàng)建也切換:git checkout -b 新分支名
? ? 合并分支:git merge 要合并的分支
? 刪除分支: git branch -d 分支
? 解決沖突:手動解決
? 將本地分支推送到遠程
? git push origin 分支名
? 將刪除遠程分支
? git push origin :分支名
拉取遠程分支并創(chuàng)建本地分支
git fetch origin 遠程分支名x:本地分支名x
? 三、打版本
? ? 查看版本: git tag
? ? 打版本: git tag 版本號
? ? 推送版本到遠程: git push origin 版本號
? ? 刪除本地版本:git tag -d 版本號
? ? 刪除遠程版本號:git push origin :refs/tags/版本號