1. 程式人生 > >git日常使用

git日常使用

pop ges git add 存在 使用 data config 克隆 content

一、git賬號配置

查看git配置 git config --list (查看user.email=***@emial 是否為自己賬號) 全局配置git賬號 git config --global user.name 你的名字 git config --global user.email 你的賬號

二、日常開發:

克隆一個本地代碼倉庫 git clone ***.git 進入文件夾 cd ** 創建本地新分支AA git checkout -b AA 將本地新分支AA與遠程分支AA相關聯 git branch --set-upstream-to=origin/AA AA 拉取遠程分支代碼,更新本地分支代碼 git pull 解決沖突ing 解決沖突end 本地開發ing 本地開發end 添加暫存區 git add . 添加進本地倉庫 git commit -m ‘相關描述’ 提交本地分支代碼到遠程分支 git push

三、存在沖突導致push不了,使用stash

緩存本地更改 git stash 拉取遠程代碼 git pull 釋放本地更改 git stash pop 解決沖突ing 解決沖突end 添加暫存區 git add . 添加進本地倉庫 git commit -m ‘相關描述’ 提交本地分支代碼到遠程分支 git push

四、兩個分支AA和BB同時開發

切換到AA分支 git checkout AA 開發ing 開發end 提交代碼 git add . git commit -m ‘相關描述’ git push 切換到BB分支 git checkout BB 開發ing 開發end 緩存本地更改 git stash 拉取遠程分支代碼 git pull 把AA分支的代碼合並到當前到BB分支 git merge origin/AA 釋放本地更改 git stash pop 解決沖突ing 解決沖突end 提交代碼 git add . git commit -m ‘相關描述’ git push

git日常使用