美文网首页
git 常用命令

git 常用命令

作者: 汉江岳 | 来源:发表于2019-12-30 17:46 被阅读0次
image.png MicrosoftTeams-image (1).png

git 用于版本控制,记录的是对文本做了那些修改。

workspace: 工作区 即当前所处的分支
index/stage: 暂存区
repository: 本地仓库
remote:远程仓库

常用命令

git init project_name
git config --global user.name "liming"
git config --global user.email "lim@gmail.com"
git add train.py
git add .
git add [dir]  # 添加指定目录到暂存区,包括子目录
git add -p
git rm train.py
git rm --cached train.py
git mv [file-orginal] [file-renamed]
git commit -m "add train.py"
git status
git remote add [代号] 远程地址.git
git push [代号] branch_name
git checkout master
git merge branch_name # 合并到本地master
git checkout branch_name
# git merge 之后回退到之前的某个版本
git reflog # 列出当前分支的所有版本号
git reset --hard [版本号] # 即head 编号
git push -f [代号] master # 将本地代码强行提交,覆盖远程git服务器代码

参考:
http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html
https://blog.csdn.net/marvel_cheng/article/details/89474792

相关文章

网友评论

      本文标题:git 常用命令

      本文链接:https://www.haomeiwen.com/subject/hrvmoctx.html