zoukankan      html  css  js  c++  java
  • Viewing A Specific Commit_12

    Too Much Scrolling

    The last few quizzes in the previous section had you scrolling and scrolling through the patch output just to get to the right commit so you could see its info. Wouldn't it be super handy if you could just display a specific commit's details without worrying about all of the others in the repo?

    There are actually two ways to do this!

    • providing the SHA of the commit you want to see to git log
    • use a new command git show

    They're both pretty simple, but let's look at the git log way and then we'll look at git show.

    You already know how to "log" information with:

    • git log
    • git log --oneline
    • git log --stat
    • git log -p

    But did you know, you can supply the SHA of a commit as the final argument for all of these commands? For example:

    $ git log -p fdf5493
    

    By supplying a SHA, the git log -p command will start at that commit! No need to scroll through everything! Keep in mind that it will also show all of the commits that were made prior to the supplied SHA.

    New Command: git show

    The other command that shows a specific commit is git show:

    $ git show
    

    Running it like the example above will only display the most recent commit. Typically, a SHA is provided as a final argument:

    $ git show fdf5493
    

    What does git show do?

    The git show command will show only one commit. So don't get alarmed when you can't find any other commits - it only shows one. The output of the git show command is exactly the same as the git log -pcommand. So by default, git show displays:

    • the commit
    • the author
    • the date
    • the commit message
    • the patch information

    However, git show can be combined with most of the other flags we've looked at:

    • --stat - to show the how many files were changed and the number of lines that were added/removed
    • -p or --patch - this the default, but if --stat is used, the patch won't display, so pass -p to add it again
    • -w - to ignore changes to whitespace

    How many rulesets are added to the CSS by commit 8d3ea36?

    Both .read-more and .read-more::after were added.

    There's a commit with the message "Convert social links from text to images". How many files were changed by this commit?

    Try using git log --oneline to find the SHA of the commit in question. Then pass the SHA to either git log --stat or git show --stat.

    请记住,在你刚开始使用Git时,能够显示仓库的历史记录可能会特别有用,

    我们需要知道提交中存储的内容,以及在提交之后如何查看它,

    This article from Udacity

  • 相关阅读:
    洛谷 P1525 关押罪犯(并查集|二分图判定&二分答案)
    洛谷 P1948 [USACO08JAN]Telephone Lines S(贪心+最短路)
    洛谷 P1315 观光公交(贪心+模拟)
    洛谷 P3258 [JLOI2014]松鼠的新家(树上差分)
    【NOIP2001】统计单词个数
    【洛谷习题】皇后游戏
    【洛谷习题】木棍加工
    【SDOI2008】仪仗队
    【洛谷习题】末日的传说
    【洛谷习题】又是毕业季I
  • 原文地址:https://www.cnblogs.com/weiweim/p/8647846.html
Copyright © 2011-2022 走看看