Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll through git history #3

Open
pixelcort opened this issue Mar 15, 2017 · 7 comments
Open

Scroll through git history #3

pixelcort opened this issue Mar 15, 2017 · 7 comments
Labels

Comments

@pixelcort
Copy link

Currently this scrolls through undo/redo history. In addition, it would be nice to scroll back through git history as well.

@mathieudutour
Copy link
Owner

Hum that's a difficult feature to conceptualise:

  • does it navigate only in the history of the current file?
    • if so, it probably won't work with the rest of the files
    • if not, it will probably be super slow
  • does it actually checkout the different commits?
    • if so, when starting to make changes after an old commit, you will need to force push
  • what do you do with the current changes to the file? I guess you need to block the feature when there is changes

@xtrasmal
Copy link

xtrasmal commented Nov 15, 2017

You would need to load the history of all commits, then play them back. This will change all other files in the project as well. Plus you need to stash the current changes or prevent scrolling when there are changes.

Another way would do git log -p myFile and see all changes of the file up to it's creation and get that into the file somehow. Then you do not need to stash anything, because all changes are added.

If you like, apparently, you can keep track of one file as explained here: https://stackoverflow.com/questions/11128434/how-can-i-use-git-to-track-versions-of-a-single-file/13336304#13336304

@szhu
Copy link

szhu commented Nov 28, 2017

Actually, Git does provide an API for viewing the contents of files at another revision, without checking them out; the command is git show. [stack overflow]

So to implement the "scroll through git history" feature, you can:

  • Run git rev-list HEAD when scrolling starts, to get a list of all parent commits.
  • Run git show REVISION:PATH_OF_CURRENT_FILE as you scroll through different revisions to get the contents.

@xtrasmal
Copy link

@szhu this will be "read-only"

@szhu
Copy link

szhu commented Dec 14, 2017

@xtrasmal can you clarify what you are referring to? I believe both your solution and mine are solutions that only read from the Git API.

@ndelangen
Copy link

This sounds cool and possibly lightly useful

@BlueCl0wn
Copy link

In Atom there is the "git-time-machine" Package from littlebee which enables a timeline where you can look at your older commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants