git无疑已经成为了大家代码版本控制最多的工具了,这其中有不少人是使用终端来进行操作git。这里列出一些超级实用的git脚本,希望可以对大家开发有所帮助。
建议大家讲下面的脚本内容,都保存成脚本,然后设置执行权限,将所在目录加入环境变量,这样使用起来更加方便。
#!/bin/bash
git branch --no-merged master
#!/bin/bash
git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'%
执行前的准备(后续无需执行该脚本),设置vim为默认的编辑器
git config --global core.editor "vim"
每次执行的脚本
#!/bin/bash
git commit -a
#!/bin/bash
git reset --hard
#!/bin/bash
git reset HEAD~
#!/bin/sh
git reset HEAD $1 && git checkout $1
用来查看当我们使用git add
之后的内容的差异
#!/bin/bash
git diff --cached
git checkout -
git branch --contains 9666b5979(commit hash)
git tag --contains 9666b5979(commit hash)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有