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

  • SEARCH
  • Home
  • 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 9138165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:13:16+00:00 2026-06-17T09:13:16+00:00

I am using Avery Pennarun’s git-subtree which is an extension to git. How do

  • 0

I am using Avery Pennarun’s git-subtree which is an extension to git.

How do I cherry-pick a commit from a sub-repo into my main repo using git subtree? Also how do I go to a specific commit in the history of the sub-repo after I have already done a git subtree pull on that prefix?

I am primarily running this in the squash commits mode.

  • 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-06-17T09:13:16+00:00Added an answer on June 17, 2026 at 9:13 am

    how do I go to a specific commit in the history of the sub-repo?

    If you have squashed the commits, then there is no way, since the squash looses the different commits.

    Otherwise, with a un-squashed subtree, you can navigate to any commit of the subtree with just the same hash that it has in the original repository from which the subtree was created.

    git subtree (without the squash) actually adds into your repository all the relevant commits from the external repository as an independent tree within your current repo. When you do a git subtree add you can notice that several commits are added (all the original commits from the external repo) and a last merge commit that moves the content from that subtree to the given directory specified with the --prefix option. In a nutshell, it checks out a branch from another unrelated repository and then merges it into your current branch by moving all that content into a given subfolder.

    All this means is that the history of the external repo is available to you, you can checkout to it just like that, having in mind that by being a completely different tree this checkout will probably modify ALL the contents of your workspace, which on big projects can be lengthy.

    This moves us to the second:

    How do I cherry-pick a commit from a sub-repo into my main repo using git subtree?

    Seems like there is not current “cherrypicking” supported by git subtree on itself. But given the implications of all the above the following can be done.

    # move yourself to the subtree commit of your choice
    git checkout <subtree-hash>
    
    # fetch commits from the subtree repository, to have available the commit you want
    # to cherry pick.
    git fetch <path-to-remote>
    
    # cherry pick the hash you want
    git cherry-pick <cherry-hash>
    
    # move back to your original branch
    git checkout <your-branch>
    
    # subtree merge your cherry pick (using the previous HEAD),
    # so that it gets moved to the correct location specified by prefix.
    git subtree merge --prefix <subtree-prefix> HEAD@{1}
    
    # Since you probably fetched more commits that you needed from
    # the remote, you might want to clean those that where not needed
    git gc
    

    Take into consideration that after doing this if you try to git subtree pull into your subtree an update, and it includes the commit you cherry picked, you will end with a conflict since you will have two changes in the same place.

    Another more simple option, if you have access to the original subtree repository, is to make the cherry pick there in a branch and then just git subtree pull that specific branch.

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

Sidebar

Related Questions

I'm using a jQuery .each() call, which uses an anonymous function, from inside a
I'm using a framework called Processing which is basically a Java applet. It has
I am using a 3D engine called Electro which is programmed using Lua. It's
So I'm using a very basic jQuery .slideDown which is working great in FF,
I am using a HttpListener to implement a very simple http server, which is
I am using a very basic java sound class to stream audio from Bing
I'm using a memory pool class which reuses allocated memory addresses and a custom
When using SSIS to load data from a source table, we have a OLE
I'm using a (simple) basic authentication within my servlet which works well for the
I'm using a very simple jQuery live preview method which works brilliantly. But how

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.