Questions tagged [git-history-graph]

Git represents history as a directed-acyclic-graph (DAG) of commits, where each commit has at least one parent commit (the exception to this are root commits).

Git represents history as a directed-acyclic-graph (DAG) of commits, where each commit has at least one parent commit (the exception to this are root commits).

There are various tools that allow you to inspect this graph, including:

  • git log
  • git merge-base
36 questions
1908
votes
11 answers

How can I view an old version of a file with Git?

Is there a command in Git to see (either dumped to stdout, or in $PAGER or $EDITOR) a particular version of a particular file?
mike
  • 46,876
  • 44
  • 102
  • 112
437
votes
11 answers

How can I view the Git history in Visual Studio Code?

I can execute various Git commands from Visual Studio Code, however I couldn't find a way to visualize the history.
rlesias
  • 4,786
  • 3
  • 15
  • 20
86
votes
5 answers

How can I tell if one commit is an ancestor of another commit (or vice-versa)?

Git is a DAG of snapshots, with each node on the graph representing a commit. Each commit can have 'n' parent commits. Given any two commits, is there a single, concise way to discern the "order" of these two in the DAG. git rev-list seems to be…
Chris Cleeland
  • 4,760
  • 3
  • 26
  • 28
6
votes
3 answers

How to find whether a given commit is on the first-parent chain of a branch

I'm trying to script a way to tell if a given commit is on the first-parent chain of a given branch. So, for example, merge-base won't fly, as the commit might have been merged in. I want to know whether the exact commit was ever the tip of the…
Steve Benz
  • 298
  • 2
  • 8
5
votes
1 answer

Change the root commit parent to point to another commit (connecting two independent git repositories)

I have a project that has more than 3 years of history in the svn repository. It was migrated to git, but the guy who did this, just take the last version and throw out all these 3 years of history. Now the project has the last 3-4 months of history…
lmcarreiro
  • 5,312
  • 7
  • 36
  • 63
5
votes
1 answer

Git log for only part of a file?

https://stackoverflow.com/a/5493663/1172541 explains how you can do a git log command for a file. Is there a way to track how part of a file changed with git log or other git command? (Of course, this would definitely strains git's diff engines, as…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
5
votes
2 answers

Git merge only the final result of a development branch

If a Git repository structure looks like this: master: A-C dev: \B-D-E is it possible to merge the development branch into master so that only one commit is added to master, containing all of the changes found in all of the commits in the…
Bobulous
  • 12,967
  • 4
  • 37
  • 68
4
votes
0 answers

visual studio code built-in story for reviewing git commit history and doing diffs of its contents

In this SO question details are provided on use of out of box vscode "Timeline view" experience is covered as a way to look at commit history and diffs from a file scope perspective. Does out of box vscode support exist for gui review of a commit…
myusrn
  • 1,050
  • 2
  • 15
  • 29
4
votes
2 answers

Git: merge two repositories one over the other

I have a repository A (the original one) having its full set of commits. At a point in time it was decided that repository A wouldn't be used anymore and a new clean repository B was created from scratch putting all repo A's contents using copy +…
Ivan Caravanio
  • 597
  • 1
  • 7
  • 20
4
votes
3 answers

How do I see a commit's path through git history, or "how it got in the current branch"?

I'm looking in the commit history using gitk and git log and I'm trying to see how a specific commit arrived in a certain branch. I can see the commits in the history, so I know they are there. What I want to understand is how they got merged (they…
Ehryk
  • 1,930
  • 2
  • 27
  • 47
3
votes
3 answers

How to delete an specific old commit without deleting the changes in the code (i.e change the git story basically)

I have a repository, it's only mine, so there's no problem on breaking anything. Also there's only one branch, I think that makes things easier. Let's say I have this 7 commits: A -> B -> C -> D -> E -> F -> G And I want to delete commits C and D A…
Octaviotastico
  • 124
  • 5
  • 13
2
votes
1 answer

This git log output shows two branches as if they weren't branches? Please explain

feature/XY is the name of a feature branch and is currently checked out. feature/XY-refactor is the name of another branch, that branched off of feature/XY. When I run git log --oneline, I get the output below. What does it mean that these two are…
TMOTTM
  • 3,286
  • 6
  • 32
  • 63
2
votes
1 answer

git: what is difference between tilde (~) and caret (^)

Below is the git output for show-rev $ git name-rev --all 2651919f941c11581c794b40aadb2028c4f52ab4 joincolumn_issue 2617f2a1410ce0ec8ea268bbb073008b73490e78 master~2 292def505dd3cdbfd9ac974396775683b5f4c288…
samshers
  • 1
  • 6
  • 37
  • 84
1
vote
1 answer

git Second Order History

When working on a patchest, I'm expected to provide a set of clean commits. Therefore I often find myself rewriting history repeatedly before my commit-set is clean and ready to be merged. In this process, after receiving comments from reviewers, I…
Amir Gonnen
  • 3,525
  • 4
  • 32
  • 61
1
vote
1 answer

Determine parent branch/commit from git history

I've got following history in git: * 02e085a (master) readme update | * 1d940da (HEAD -> b1) search.py | | * 7aaa12d (b2) file2 | |/ | * 7be9db9 file1 |/ * 22601c0 initial commit Now I'm on b2 and I would like to get the point, where b2 branched…
ST Renegade
  • 311
  • 3
  • 14
1
2 3