Tool for searching across branches and through history in a Git repository

Multi tool use
I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find
/grep
-like). It would need to be able to search not just in the currently checked out branch, but through that branch's history as well as in other branches.
The very specific example of a Git repository that I have is a checkout of dspinellis' unix-history-repo
. I often look for historical implementations of things in there, but it's a pain to track down files as I often need to guess what branch I need to be looking at (there are 165 branches in that repository).
Example of thing I would like to do with this tool is to find the wow
command, which may have been an external command or a built-in command in sh
or csh
at some point, if it existed as part of some early BSD Unix (if it existed at all). To do this, I would want to search for wow.*
as a filename pattern, and also for files that may at some point have included a wow
C function, across the 165 branches of dspinellis' Git repository.
git search software-rec
add a comment |
I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find
/grep
-like). It would need to be able to search not just in the currently checked out branch, but through that branch's history as well as in other branches.
The very specific example of a Git repository that I have is a checkout of dspinellis' unix-history-repo
. I often look for historical implementations of things in there, but it's a pain to track down files as I often need to guess what branch I need to be looking at (there are 165 branches in that repository).
Example of thing I would like to do with this tool is to find the wow
command, which may have been an external command or a built-in command in sh
or csh
at some point, if it existed as part of some early BSD Unix (if it existed at all). To do this, I would want to search for wow.*
as a filename pattern, and also for files that may at some point have included a wow
C function, across the 165 branches of dspinellis' Git repository.
git search software-rec
add a comment |
I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find
/grep
-like). It would need to be able to search not just in the currently checked out branch, but through that branch's history as well as in other branches.
The very specific example of a Git repository that I have is a checkout of dspinellis' unix-history-repo
. I often look for historical implementations of things in there, but it's a pain to track down files as I often need to guess what branch I need to be looking at (there are 165 branches in that repository).
Example of thing I would like to do with this tool is to find the wow
command, which may have been an external command or a built-in command in sh
or csh
at some point, if it existed as part of some early BSD Unix (if it existed at all). To do this, I would want to search for wow.*
as a filename pattern, and also for files that may at some point have included a wow
C function, across the 165 branches of dspinellis' Git repository.
git search software-rec
I'm looking for a tool, or for suggestions towards a script, that would be able to search a Git repository for files based on both filenames and file contents (find
/grep
-like). It would need to be able to search not just in the currently checked out branch, but through that branch's history as well as in other branches.
The very specific example of a Git repository that I have is a checkout of dspinellis' unix-history-repo
. I often look for historical implementations of things in there, but it's a pain to track down files as I often need to guess what branch I need to be looking at (there are 165 branches in that repository).
Example of thing I would like to do with this tool is to find the wow
command, which may have been an external command or a built-in command in sh
or csh
at some point, if it existed as part of some early BSD Unix (if it existed at all). To do this, I would want to search for wow.*
as a filename pattern, and also for files that may at some point have included a wow
C function, across the 165 branches of dspinellis' Git repository.
git search software-rec
git search software-rec
asked Jan 10 at 15:50


KusalanandaKusalananda
124k16234385
124k16234385
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow*
wow
can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can then check the tree out at that point and explore further.
To search file contents across all branches, I use
git rev-list --all | xargs git grep "excited too"
which lists all commit objects and searches through them. This is very, very slow on the Unix history repository; listing all the branches and grepping there is quicker:
git grep "excited too" $(git branch -r | awk '{print $1}')
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... Thegit rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.
– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493747%2ftool-for-searching-across-branches-and-through-history-in-a-git-repository%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow*
wow
can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can then check the tree out at that point and explore further.
To search file contents across all branches, I use
git rev-list --all | xargs git grep "excited too"
which lists all commit objects and searches through them. This is very, very slow on the Unix history repository; listing all the branches and grepping there is quicker:
git grep "excited too" $(git branch -r | awk '{print $1}')
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... Thegit rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.
– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
add a comment |
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow*
wow
can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can then check the tree out at that point and explore further.
To search file contents across all branches, I use
git rev-list --all | xargs git grep "excited too"
which lists all commit objects and searches through them. This is very, very slow on the Unix history repository; listing all the branches and grepping there is quicker:
git grep "excited too" $(git branch -r | awk '{print $1}')
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... Thegit rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.
– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
add a comment |
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow*
wow
can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can then check the tree out at that point and explore further.
To search file contents across all branches, I use
git rev-list --all | xargs git grep "excited too"
which lists all commit objects and searches through them. This is very, very slow on the Unix history repository; listing all the branches and grepping there is quicker:
git grep "excited too" $(git branch -r | awk '{print $1}')
Heh, guess what I’ve been doing too...
To look for a file name across all branches, I use
git log --all --name-only --pretty=format:%H -- wow*
wow
can be replaced by any glob. This runs quite quickly on the Unix history repository. The format shows the hash leading to the creation of the matching file, so you can then check the tree out at that point and explore further.
To search file contents across all branches, I use
git rev-list --all | xargs git grep "excited too"
which lists all commit objects and searches through them. This is very, very slow on the Unix history repository; listing all the branches and grepping there is quicker:
git grep "excited too" $(git branch -r | awk '{print $1}')
edited Jan 10 at 16:17
answered Jan 10 at 16:11
Stephen KittStephen Kitt
166k24370451
166k24370451
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... Thegit rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.
– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
add a comment |
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... Thegit rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.
– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... The
git rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.– Kusalananda
Jan 10 at 16:22
This is very useful! Thanks Stephen. I will see if I can wrap these commands in convenience functions... The
git rev-list --all
command outputs exactly 400200 hashes (for this particular repository), so yes, I can imagine that it would be rather slow. It would include the older commits of each branch though (I presume), i.e. not just the latest version, so the search would be more thorough.– Kusalananda
Jan 10 at 16:22
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
Yes, it would be more thorough ;-). Another approach specifically with the Unix history repo would be to use the source repo and associated downloads, and search those instead.
– Stephen Kitt
Jan 10 at 16:28
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493747%2ftool-for-searching-across-branches-and-through-history-in-a-git-repository%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
wc NXB0yyxvtqEgkDd7C2