zoukankan      html  css  js  c++  java
  • Git命令一览

    1、git diff

    • 比较两个分支间所有变更的文件列表
      git diff branch1 branch2 --stat

    2、git push

    • 将tag推到远程仓库(git push origin master并不会把tag推上去)
      git push origin --tags

    3、git rebase

    • 在自己的分支上合并master分支上面的提交,git rebase过程相比较git merge合并整合得到的结果没有任何区别,但是通过git rebase衍合能产生一个更为整洁的提交历史。
      git rebase master
    • —rebase 并不会产生一个commit提交
      git pull --rebase
    • git rebase master以后,要git pull -f 才能将分支推到线上去
      git push -f
    • 如果rebase之后发生冲突,解决完冲突后先git add . , 再git rebase --continue

    4、git stash

    • 如果pull的时候产生冲突,可以先git add . ,再git stash, git stash drop, 然后切到别的分支,git branch -D 删除此分支, 再将远程分支拉下来

    5、git reset --hard origin/master

    当我们将当前分支(如master)reset到之前的提交,并且我们git push -f 能将本地的分支(master)推到远程仓库去的时候,如果我们在另一台机器上面再git pull的时候会提示以下错误:
    Your branch and 'origin/mastert' have diverged, and have 1 and 1 different commit each, respectively
    这个时候如果另一台机器不需要报存本地提交直接替换成远程的仓库的话,使用git reset --hard origin/master,就能将本地仓库变成跟远程仓库一样了。

    5、git log

    git log --graph --decorate --oneline --all 查看git提交历史的点线图,如下图所示:

    设置git lg为查看当前分支提交记录
    git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"
    设置git lga为查看所有分支的提交记录
    git config --global alias.lga "log --color --date-order --date=format:'%Y-%m-%d %H:%M:%S' --graph --format=\"%C(auto)%h%Creset %C(blue bold)%cd%Creset %C(green)[%an]%Creset %C(auto)%d%Creset %s\" --all"

  • 相关阅读:
    P1281 书的复制 dp
    P3402 最长公共子序列(nlogn)
    P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers
    P1202 黑色星期五
    P1205 方块转换
    [递推] hihocoder 1239 Fibonacci
    [二分] hihoCoder 1269 优化延迟
    [分治] POJ 3233 Matrix Power Series
    使用HTMLParser解析html
    CSAPP2e: Proxy lab 解答
  • 原文地址:https://www.cnblogs.com/lanlingshao/p/9566888.html
Copyright © 2011-2022 走看看