小工具使用之git

常用git命令:
1.配置项:
git config --global --help
一般配置项为用户名 邮箱 对比工具 命令缩写 其他现在还没有用到;
2. 新建初始化库
git init
git clone url
3.代码提交
git add .
git rm [file]
git rm --cached [file] 停止追踪文件
git commit -m
git commit --amend
git commit
git cherry-pick commitId

4.branch
git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout -b [branch]
git branch [branch] [commit]
新建一个分支并与远程分支建立track关系
git branch --track [branch] [remote-branch]
git checkout -b [branch-name] [remote-branch]
git checkout [branch-name]
git checkout - //切换到上一个分支
在现有分支与指定的远程分支之间建立track 关系
git branch --set-upstream [branch] [remote-branch]
git merge [branch]
git cherry-pick [commit]
git branch -d [branch-name]
git push origin --delete [branch-name]
5.log
git log
git log -n
git log --stat
git log --follow [file] //显示某个文件的版本历史
git log -p [file] //显示指定文件相关的每一次diff
git shortlog -sn //显示所有提交过的用户,按提交次数排序
git blame [file] //显示指定文件是什么人在什么时间修改过
git reflog
git diff //暂存区与工作区的差异
git diff --cached [file]
git diff HEAD //工作区与仓库最新的commit的差异
git diff [first-commit]…[second-commit]
git diff --shortstat “@{0 day ago}” //显示今天你写了多少行代码
git show [commit] //显示某次提交的元数据和内容变化
git show --name-only [commit] //显示某次提交发生变化的文件
git show [commit]:[filename] //显示某次提交时,某个文件的内容
6.push and pull
git push remote branch
git pull remote branch
git fetch [remote] 更新本地仓库
git remote -v
git rebase
git merge
7.tag
git tag [tag]
8.代码回退
git checkout – .
git checkout [file]
git checkout [commit] [file]
git reset [file] //从暂存区中捞出误增加的文件
git reset [commit]
git reset --hard
git stash
git stash save -u “statement”
git stash list
git stash pop stash@{0}
git revert commit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值