Git-Pro Git前三章笔记+日常使用命令

本文记录一些学习《Pro Git》book的一些笔记和工作中常用到的一些git指令。

  • git相当于一个小型文件系统,保存的是各个不同版本的文件,而非版本之间的修改。
  • git config 分为三级,–system所有用户,–global当前用户,–local当前项目。后两个比较常用同样的配置项下一级会覆盖上一级
  • git config --list --show-origin
    列出已配置的项以及配置文件的位置
  • git config --global user.name “John Doe”
    刚安装完git通常要执行的命令,否则无法commit
  • git config --global user.email johndoe@example.co
    刚安装完git通常要执行的命令,否则无法commit
  • git init
    新建本地仓库
  • git clone url
    拉取远端项目到本地
  • git clone url newName
    拉取项目到本地,且文件夹名字为newName
  • git add file
    将文件添加到暂存区
  • git add -u
    添加所有已修改和删除的tracked files到暂存区,不包括新增
  • git reset HEAD file
    将文件从暂存区移出
  • git checkout – file
    将文件变为上一次add或者commit的最新状态
  • git diff
    比较的是工作区与暂存区之间的变化
  • git diff --cached或者–staged
    比较暂存区与最新一次提交之间的变化
  • git status
    查看当前仓库状态
  • git commit
    提交,提交信息使用默认编辑器编辑
  • git commit -m “123”
    提交,提交信息-m之后的信息
  • git commit -a (–all)
    等价于git add -u加git commit
  • git rm file
    不再跟踪文件且删除工作区文件,支持正则表达式
  • git rm --cached file
    不再跟踪文件且保留工作区文件,支持正则表达式
  • git mv nameA nameB
    重命名或者移动。等价于三个指令mv README.md README+git rm README.md+git add README
  • git log
    查看提交历史
  • git log -n
    显示n次提交历史
  • git log -p(–patch)
    显示每次提交所引入的差异(每次提交与上一次提交的变化)
  • git log --pretty=oneline
    每次提交信息只显示一行
  • git log --pretty=oneline --graph
    –graph以分支图的形式显示信息
  • git log --since=2022-01-01
    显示时间点以来的提交
  • git rebase master
    将当前分支rebase到master分支
  • git rebase master dev
    将dev分支rebase到master分支
  • git rebase -i HEAD~2
    合并最近的2次提交
  • git rebase --continue
    继续rebase过程
  • git rebase --abort
    撤销此次rebase过程
  • git config --global merge.tool meld
    使用meld解决冲突
  • git mergetool
    当前仓库存在冲突时,使用配置好的冲突解决工具解决冲突
  • git reset hash
    重置HEAD指针到指定hash,不改变工作区内容
  • git reset --hard hash
    重置HEAD指针到指定hash,且改变工作区内容到指定hash版本
  • git stash -m “message”
    将当前工作区未commit的修改放到stash中
  • git stash apply 0
    应用索引0的stash,但不删除
  • git stash pop 0
    应用索引0的stash,且删除
  • git checkout -b branch_name
    创建新分支并切换到该分支
  • git checkout branch_name
    切换分支
  • git checkout branch_name --recursive-modules
    所有仓库和子仓库切换到指定分支
  • git pull --recursive-modules
    拉取所有仓库和子仓库
  • git commit --amend
    重新提交上次commit
  • git tag
    显示已有标签
  • git tag -a tag_name -m “message” [HASH]
    给当前commit添加annotated tag附注标签,包含打标签者的名字、电子邮件地址、日期时间, 此外还有一个标签信息,带上hash给指定commit加tag
  • git tag tag_name [HASH]
    给当前commit添加lightweight tag轻量标签,带上hash给指定commit加tag
  • git push origin tag_name
    push 标签
  • git push --tags
    push所有标签
  • git tag -d tag_name
    删除标签
  • git push origin --delete tag_name
    删除远程标签
  • git config --global alias.last ‘log -1 HEAD’
    命令别名。git last==git log -1 HEAD
  • git remote prune origin
    远程仓库分支删除后,删除相应的引用
  • git branch
    查看本地分支和当前分支
  • git branch -d branch_name
    删除本地分支
  • git branch --merged [branch_name]
    查已经merge到当前分支/branch_name分支的所有分支,
  • git branch --no-merged [branch_name]
    查没有merge到当前分支/branch_name分支的所有分支
  • git merge branch_name
    在当前分支创建合并分支节点,并合并branch_name分支到当前分支
  • git checkout -b serverfix origin/serverfix
    创建分支本地分支serverfix,并1. 切换到该分支 2. 设置远程仓库origin上的serverfix远程分支为跟踪的分支
  • git fetch
    命令从服务器上抓取本地没有的数据,它并不会修改工作目录中的内容。 它只会获取数据然后让你自己合并
  • git pull
    它的含义是一个 git fetch 紧接着一个 git merge 命令
  • git push origin -d serverfix
    从origin仓库中删除分支serverfix
  • git rebase --onto master server client
    取出 client 分支,找出它从 server 分支分歧之后的补丁, 然后把这些补丁在 master 分支上重放一遍,让 client 看起来像直接基于 master 修改一样
    在这里插入图片描述
    在这里插入图片描述
  • git rebase basebranch topicbranch
    topicbranch变基到basebranch

(Pro Git 前三章完结)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Pro Python 第2版,2014.12.17出版的新书 You’ve learned the basics of Python, but how do you take your skills to the next stage? Even if you know enough to be productive, there are a number of features that can take you to the next level in Python. Pro Python, Second Edition explores concepts and features normally left to experimentation, allowing you to be even more productive and creative. In addition to pure code concerns, Pro Python develops your programming techniques and approaches, which will help make you a better Python programmer. This book will improve not only your code but also your understanding and interaction with the many established Python communities. This book takes your Python knowledge and coding skills to the next level. It shows you how to write clean, innovative code that will be respected by your peers. With this book, make your code do more with introspection and meta-programming. And learn and later use the nuts and bolts of an application, tier-by-tier as a complex case study along the way. This book is for intermediate to advanced Python programmers who are looking to understand how and why Python works the way it does and how they can take their code to the next level. Table of Contents 1. Principles and Philosophy 2. Advanced Basics 3. Functions 4. Classes 5. Common Protocols 6. Object Management 7. Strings 8. Documentation 9. Testing 10. Distribution 11. Sheets: A CSV Framework 12. Style Guide for Python 13. Voting Guidelines 14. The Zen of Python 15. Docstring Conventions 16. Backward Compatibility Policy 17. Python 3000 18. Python Language Moratorium

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mrbone11

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值