git-log

How to view file history in Git?

假如想象 提交于 2019-12-17 17:22:17
问题 With Subversion I could use TortoiseSVN to view the history/log of a file. How can I do this with Git? Just looking for history record for a particular file, and then the ability to compare the different versions. 回答1: Use git log to view the commit history. Each commit has an associated revision specifier that is a hash key (e.g. 14b8d0982044b0c49f7a855e396206ee65c0e787 and b410ad4619d296f9d37f0db3d0ff5b9066838b39 ). To view the difference between two different commits, use git diff with the

How to invert `git log --grep=<pattern>` or How to show git logs that don't match a pattern

旧街凉风 提交于 2019-12-17 10:44:54
问题 I want to use git log to show all commits that do not match a given pattern. I know I can use the following to show all commits that do match a pattern: git log --grep=<pattern> How do I invert the sense of matching? I am trying to ignore commits that have "bumped to version ..." in the message. EDIT: I want my final output to be pretty verbose. e.g. git log --pretty --stat . So output from git log --format=oneline won't work for me. 回答1: Generate a list of all commits, subtract those whose

git - Find commit where file was added

假如想象 提交于 2019-12-17 04:12:29
问题 Say I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added. After reading the answers and my own tinkering, this works for me git log --follow --diff-filter=A --find-renames=40% foo.js 回答1: Here's simpler, "pure Git" way to do it, with no pipeline needed: git log --diff-filter=A -- foo.js Check the documentation. You can do the same thing for Deleted, Modified, etc. https://git-scm.com/docs/git-log#Documentation/git-log

Pretty git branch graphs

拟墨画扇 提交于 2019-12-16 19:42:09
问题 I've seen some books and articles have some really pretty looking graphs of git branches and commits. How can I make high-quality printable images of git history? 回答1: Update: This answer has gotten far more attention than it deserves. It was originally posted because I think the graphs look nice and they could be drawn-over in Illustrator for a publication– and there was no better solution. But there now exists much more applicable answers to this Q, such as fracz's, Jubobs', or Harry Lee's!

Start GitLog with Java Process Builder

蹲街弑〆低调 提交于 2019-12-13 17:18:36
问题 I try to start a GitLog command via Processbuilder in Java. GitLog Command : git --git-dir=C:/Users/User/Code/code1/git/.git log --pretty=format:"%H \"%an\" %ad \"%s\"" --numstat --date=short This is my code. The Path is the path to the git dir. I hardcoded the gitpath to the git dir for testing. public void createGitLog( Path path ) { try { String gitpath = "--git-dir=C:/Users/User/Code/code1/git/.git"; String options = "--pretty=format:\"%H \\\"%an\\\" %ad \\\"%s\\\"\" --numstat --date

Visualize git branch dependency

我怕爱的太早我们不能终老 提交于 2019-12-13 12:35:07
问题 Is there a tool that can show me what branches a specific branch has been merged into? For example, if "A" has been merged into "B" and "C" but not "D", how do I output "B" and "C"? I'd only need the branch names. 回答1: If you mean a graphic tool, gitk would seem to be a good starting point. Alternatively, you might prefer the CLI which is very useful for some needs, give it a try : git log --oneline --decorate --simplify-by-decoration --graph --all And to adress more specifically the question

How can a patchfile created with `git-log -p <filename>` be applied to create all the commits included?

强颜欢笑 提交于 2019-12-13 07:29:41
问题 Background: this question. git apply <patchfile> just recreates the file but without committing the history, which in this case would be desireable. Is there any switch for git-apply to do so? Or is there a way to convert the patchfile into a git-am compatible file? (Currently, git-am complains "Patch format detection failed") 回答1: You asked, so here it is. I used this script, but it's all rather fragile. Treat it an as inspiration, not as a reasonable solution. It extracts (date / author /

git space between pretty format placeholders

有些话、适合烂在心里 提交于 2019-12-13 03:57:19
问题 For some reason (this reason) I will probably have to run a git command like this: git log --pretty=format:{\"author\":\"%aE <%aD>\"} but it doesn't work and I obtain this error information: fatal: ambiguous argument '<%aD>"}': unknown revision or path not in the working tree. but the same command whithout the space works well: git log --pretty=format:{\"author\":\"%aE<%aD>\"} Do you know how to fix this or how to insert a space "programmatically" with another placeholder? Thanks! 回答1: Since

An alias for git's --pretty option string format

我是研究僧i 提交于 2019-12-12 20:34:20
问题 I know I can set an alias for git log invocation with lots of parameters. For example, I can use this: git config --global alias.lg "log --graph --pretty=format:'%h -%d %s (%cr) <%an>'" to alias git log --graph --pretty=format:'%h -%d %s (%cr) <%an>' with much shorter git lg . Is it possible to set an alias for a --pretty=format: string alone? So that I can type git log --pretty=my_aliased_format 回答1: The git log documentation has this to say about the --pretty[=<format>] and --format=<format

msysGit: Why does git log output blank lines?

白昼怎懂夜的黑 提交于 2019-12-12 14:17:19
问题 It appears to insert less blank lines the closer I type the command to the bottom of the terminal window. If I type it at the top of the terminal window, it inserts nearly a full window height of blank lines; if I type it at the very bottom, no blank lines are inserted. It seems like the pager program is pushing output to the bottom of the terminal window, but I want the output to be right below my command or at the top, like in Linux git. I can get expected behavior by using git --no-pager