git日常使用

一、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
 
posted @ 2018-12-21 17:10  Alice_Xu  阅读(262)  评论(0编辑  收藏  举报