git usage documentation
-
Git installation
download address: git official website -
git detailed instructions document git official document
- Install ssh password-free upload and download code
- Generate ssh [No brain next step, replace 123... with your own mailbox]
ssh-keygen -t rsa -C "[email protected]"
- Copy the SSH Key and add it to the SSH settings
cat ~/.ssh/id_rsa.pub
- git global setting current user
git config --global user.name "用户名"
git config --global user.email "邮箱@qq.com"
- download item
git clone [email protected]:project/path.git
- Project branch description
// 查看当前分支
git branch
// 查看所有分支
git branch -a
// 新建分支
git branch newBranch
切换分支
git checkout newBranch
// 删除本地分支
git branch -d newBranch
// 删除远程分支
git push origin --delete newBranch
- view current modification
// 对比文件更新的具体内容
git diff
// 对比本地仓库的文件更新状态
git status
- drop down/update item
git pull
- Save and upload to remote warehouse
// 保存所有修改到本地暂存区
git add -A
// 提交到本地仓库
git commit -m "commit introduce"
// 上传的到远程仓库master分支
git push origin/master
- rollback to previous version
// 查看历史提交版本
git log
// 回退到指定hash版本
git reset --hard dde8c25694f34acf8971f0782b1a676f39bf0a46
- Resolve conflicts (local and remote warehouse versions are different)
- There are modifications locally, and both local and remote codes are saved
// 挂起/暂存/备份本地修改版本
git stash
// 下拉远程版本
git pull
// 查看挂起版本 查看后 --> stash@{
0}
git stash list
// 获取备份
git stash pop stash@{
0}
// 对比手动解决冲突
- There is a local modification, discard and overwrite the local modification (use with caution)
// 下拉并同步远程仓库版本
git fetch --all
// 使用远程master版本覆盖本地修改
git reset --hard origin/master
- merge branch
// 开发结束 切换当前分支为master,并合并开发分支
git merge dev
- Determine the version (label v1.0/v2.0...)
// 查看所有标签
git tag
// 创建新标签 -a版本号 -m当前版本说明
git tag -a v1.0 -m "my version 1.0"
// 删除标签
git tag -d v1.0
// 上传创建标签到远程仓库
git push origin --tags