准备工作
-
在本地Win上在本地安装GIT工具和MINGW64,VIM,VS CODE
-
安装Git工具
https://github.com/git-for-windows/git/releases/download/v2.34.0.windows.1/Git-2.34.0-64-bit.exe
-
安装MINGW64
Find out more about MinGW-w64 - for 32 and 64 bit Windows | SourceForge.net
-
安装vim
-
https://ftp.nluug.nl/pub/vim/pc/gvim82.exe
- 安装 VS CODE
https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-us
-
在本地linux,mac上
-
无需操作,一般都有这些工具
-
常用命令
-
git clone
-
git init 初始化本地仓库
-
git add . 将当前目录放入暂存区
-
git config
-
git config --global user.email "you@example.com"
-
git config --global user.name "Your Name "
-
-
git commit –m "test" 提交到本地,备注信息test
-
git push 推送到远程仓
(一共有本地,暂存和.git 三个部分)
-
git checkout –b 分支名 新建一个代码分支
-
等价于两条命令
-
新建分支 :git branch 分支名
-
切换分支 : git cheackout 分支名
-
-
-
git push --set-upstream origin 分支名 推送本地分支到远程地址
-
git branch 分支名 origin/分支名 获取远程分支到本地
-
git branch -a 查看所有分支
-
git clone -b 分支名 仓库地址 clone获取分支
-
git merge 分支名 在当前分支,合并分支。
-
git log --oneline --graph 以图形方式查看git记录
-
git reset --hard HEAD^ 回滚到上一轮提交,几个尖号回滚几次
小组合作用git
-
小组成员代码提交到自己的分支
-
组长将他们合并到master分支上
-
遇到冲突:合并失败
-
vim xxx 手动更改
-
再add commit push merge
-
-
分布式的版本控制仓库,可靠性高
git 多人合作工作流
-
组员写代码 并推送到远程仓库
-
git pull 更新代码
-
git checkout –b 分支名 新建一个代码分支
-
git add .
-
git commit –m "test" 提交到本地,备注信息test
-
git push
-
git push <远程主机名> <本地分支名> <远程分支名>
-
git push -- set-upstream origin 分支名 推送到自己的仓库
-
-
-
-
git branch –a (非必要)查看远端分支创建是否成功
-
pull request 发起请求
-
-
组长 选择接受或拒绝 pull request