2023/7/11大约 1 分钟
git的基本使用
将远程仓库克隆到本地
git clone https://gitee.com/用户个性地址/HelloGitee.git设置备注
git config --global user.name "你的名字或昵称"git config --global user.email "你的邮箱"git add . #将当前目录所有文件添加到git暂存区
git commit -m "my first commit" #提交并备注提交信息git push origin master #将本地提交推送到远程仓库 git push origin master --force 强制提交强制上传
git push -u origin master -f
多人协作的工作模式
- 首先,可以尝试用
git push origin <branch-name>推送自己的修改; - 如果推送失败,则因为远程分支比你的本地更新,需要先用
git pull试图合并; - 如果合并有冲突,则解决冲突,并在本地提交;
- 没有冲突或者解决掉冲突后,再用
git push origin <branch-name>推送就能成功! - 如果
git pull提示no tracking information,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream-to <branch-name> origin/<branch-name>。
配置简略命令
例如 git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"