Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 195285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:40:04+00:00 2026-05-11T16:40:04+00:00

I have a Git repository with few branches and dangling commits. I would like

  • 0

I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string.

I know how to get a log of all commits in history, but these don’t include branches or dangling blobs, just HEAD’s history. I want to get them all, to find a specific commit that got misplaced.

I would also like to know how to do this in Mercurial, as I’m considering the switch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:40:04+00:00Added an answer on May 11, 2026 at 4:40 pm

    You can see dangling commits with git log -g.

    -g, --walk-reflogs
     Instead of walking the commit ancestry chain, walk reflog entries from
     the most recent one to older ones. 
    

    So you could do this to find a particular string in a commit message that is dangling:

    git log -g --grep=search_for_this
    

    Alternatively, if you want to search the changes for a particular string, you could use the pickaxe search option, “-S”:

    git log -g -Ssearch_for_this
    # this also works but may be slower, it only shows text-added results
    git grep search_for_this $(git log -g --pretty=format:%h)
    

    Git 1.7.4 will add the -G option, allowing you to pass -G<regexp> to find when a line containing <regexp> was moved, which -S cannot do. -S will only tell you when the total number of lines containing the string changed (i.e. adding/removing the string).

    Finally, you could use gitk to visualise the dangling commits with:

    gitk --all $(git log -g --pretty=format:%h)
    

    And then use its search features to look for the misplaced file. All these work assuming the missing commit has not “expired” and been garbage collected, which may happen if it is dangling for 30 days and you expire reflogs or run a command that expires them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your view doesn't have to do much. tasks = Tasks.objects.all()… May 12, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer A complete answer to your question depends on the "real-world… May 12, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer scope(X) isn't necessary in the same way that for isn't… May 12, 2026 at 9:03 am

Related Questions

I'm trying to get started using git, but I'm having some troubles right away.
I have a Git repository and I'd like to see how some files looked
I have a local Git repository I've been developing under for a few days:
I have downloaded Privoxy few weeks ago and for the fun I was curious

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.