Git基本命令
配置
git config
git config -- global user.name "songxxxxx"
git config -- global user.email 1773259xxx@qq.com
git config -- global url.git@github.com:.insteadOf github.com/
git config -- global alias.cin "commit -- amend -- no-edit:
git remote
git remote add origin_ssh git@github.com::git/git.git
HTTP Remote
免密 git config -- global credential.helper 'cache -- timeout=3600'
硬盘 git config -- global credential.helper "store -- file/path/to/credential-file"
SSH Remote
免密配置 dsa、rsa、ecdsa、ed25519
提交代码
git add
git commit
追溯历史版本 git commit -m "hello world"
修改历史版本 git commit - amend
远端同步
控制代码
clone 拉取完整的仓库到本地目录,可以指定分支、深度
pull 拉取远端分支,并和本地代码合并,相当于git fetch + git merge,可能存在冲突
fetch 将远端的某些分支最新代码拉取到本地,不会执行merge操作,会修改refs/remote的分支信息,如果需要和本地代码合并需要手动操作
推送代码
push
Git研发流程
工作流
集中式工作流
只依托于主干分支进行开发,不存在其他分支
分支管理工作流
可以定义不同特性的开发分支,上线分支,在开发分支完成开发后再通过MR/PR合入主干分支