自己常用的git命令

  1. git clone

    拉取代码仓库到本地

  2. git add xxxx or git add .

    添加修改的或是新增的文件到暂存区

  3. git commit -m 'xxx'

    添加提交记录

  4. git fetch

    从远端拉取当前分支的最新记录

  5. git rebase [branch_name]

    将本地commit 衍合到本地对应分支已经跟踪到远程的最新记录之上。branch_name 为空时, 衍合当前分支。

  6. git pull

    拉取代码并合并。自己很少用这个,基本是在稳定分支上拉取最新代码。

  7. git push

    推送本地 commit 到远程仓库。

  8. git reset --hard commit_hash

  9. git checkout -b

    基于当前本地分支新建一个分支。

  10. git checkout

    切换分支

  11. git cherry-pick commit-hash

    将其他分支的 commit 挑出来合并到当前本地分支。

  12. git rebase -i HEAD~xxxx

    将当前分支的多少个 commit 进行修正,我通常作为将多个commit 合并用。

  13. git push -u origin current_branch_name

    将当前新建分支推送到远程。

  14. git diff

    查看未缓存的修改

  15. git diff --cached

    查看已被缓存的修改

  16. git diff branch_name
    当前分支对比 branch_name 分支

  17. git diff commit-hash
    当前 HEADcommit-hash 对应的 commit 对比。

  18. git show commit-hash

    查看 commit-hash 对应 commit 的详细修改, 如果没有 commit-hash 则是 当前分支的 HEAD

  19. git merge

    合并两个分支

  20. aliases:

ll = log --pretty=format:%C(yellow)%h%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --numstat
ls = log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
ls-ignored = ls-files --others --i --exclude-standard
far = "!git fetch; git rebase"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值