{"thread":{"id":"17142","subject":"How to pull remote branch with specified commit id?","startedAt":"2009-01-13T09:08:34Z","lastAt":"2009-01-14T07:02:36Z","messageCount":8,"participants":["Emily Ren","Andreas Ericsson","Johannes Sixt","Brad King","thestar@fussycoder.id.au"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"100254","messageId":"856bfe0e0901130108q3af1345cy31751dd09e030c96@mail.gmail.com","threadId":"17142","inReplyTo":null,"subject":"How to pull remote branch with specified commit id?","fromName":"Emily Ren","fromEmail":"lingyan.ren@gmail.com","sentAt":"2009-01-13T09:08:34Z","receivedAt":"2009-01-13T09:08:34Z","isPatch":false,"sender":{"key":"lingyan.ren@gmail.com","avatar":null},"body":"Git experts,\n\nI want to pull remote branch with specified commit id, how to do it?\n\nBelow command can get remote branch\n$git pull remote refs/heads/$branch_name\n\nBelow command doesn't work\n$git pull remote objects/$commit_id\n\nThanks,\nEmily\n"},{"id":"100255","messageId":"496C5BE3.2040206@op5.se","threadId":"17142","inReplyTo":"856bfe0e0901130108q3af1345cy31751dd09e030c96@mail.gmail.com","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2009-01-13T09:16:19Z","receivedAt":"2009-01-13T09:16:19Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Emily Ren wrote:\n> Git experts,\n> \n> I want to pull remote branch with specified commit id, how to do it?\n> \n> Below command can get remote branch\n> $git pull remote refs/heads/$branch_name\n> \n> Below command doesn't work\n> $git pull remote objects/$commit_id\n> \n\nYou need to fetch it first, and then merge the commit you want. The\ntools operating the fetching protocol only use refs, so if you want\nto fetch (or pull) a specific version that has neither a tag nor a\nbranch head pointing to it, you'll have to write a new tool for that.\n\nThe end-result of the following command will be, barring side-effects\nin the remote-tracking branches, identical to what you're trying to\ndo though:\ngit fetch remote && git merge $commit_id\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"100260","messageId":"496C6234.9040903@viscovery.net","threadId":"17142","inReplyTo":"856bfe0e0901130108q3af1345cy31751dd09e030c96@mail.gmail.com","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-01-13T09:43:16Z","receivedAt":"2009-01-13T09:43:16Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Emily Ren schrieb:\n> Git experts,\n> \n> I want to pull remote branch with specified commit id, how to do it?\n> \n> Below command can get remote branch\n> $git pull remote refs/heads/$branch_name\n> \n> Below command doesn't work\n> $git pull remote objects/$commit_id\n\nYou can't, and that is so by design.\n\nConsider this: You accidentally push a branch with confidential data to a\npublic repository. You notice it early, and quickly delete the branch\nusing 'git push the-repo :refs/heads/that-branch'. At this time the\nobjects with the confidential data are still lingering in the public\nrepository. But with the current behavior noone can access them even if\nthe SHA1 happens to be known.\n\n-- Hannes\n"},{"id":"100274","messageId":"856bfe0e0901130515o5739bcbft1927f42a2dd85ad3@mail.gmail.com","threadId":"17142","inReplyTo":"496C5BE3.2040206@op5.se","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Emily Ren","fromEmail":"lingyan.ren@gmail.com","sentAt":"2009-01-13T13:15:03Z","receivedAt":"2009-01-13T13:15:03Z","isPatch":false,"sender":{"key":"lingyan.ren@gmail.com","avatar":null},"body":"Andreas,\n\nI tried your method, it works. Thank you very much !\n\nEmily\n\nOn Tue, Jan 13, 2009 at 5:16 PM, Andreas Ericsson <ae@op5.se> wrote:\n> Emily Ren wrote:\n>>\n>> Git experts,\n>>\n>> I want to pull remote branch with specified commit id, how to do it?\n>>\n>> Below command can get remote branch\n>> $git pull remote refs/heads/$branch_name\n>>\n>> Below command doesn't work\n>> $git pull remote objects/$commit_id\n>>\n>\n> You need to fetch it first, and then merge the commit you want. The\n> tools operating the fetching protocol only use refs, so if you want\n> to fetch (or pull) a specific version that has neither a tag nor a\n> branch head pointing to it, you'll have to write a new tool for that.\n>\n> The end-result of the following command will be, barring side-effects\n> in the remote-tracking branches, identical to what you're trying to\n> do though:\n> git fetch remote && git merge $commit_id\n>\n> --\n> Andreas Ericsson                   andreas.ericsson@op5.se\n> OP5 AB                             www.op5.se\n> Tel: +46 8-230225                  Fax: +46 8-230231\n>\n"},{"id":"100328","messageId":"496D0E65.3000200@kitware.com","threadId":"17142","inReplyTo":"496C6234.9040903@viscovery.net","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Brad King","fromEmail":"brad.king@kitware.com","sentAt":"2009-01-13T21:57:57Z","receivedAt":"2009-01-13T21:57:57Z","isPatch":false,"sender":{"key":"brad.king@kitware.com","avatar":"https://avatars.githubusercontent.com/u/87268?v=4"},"body":"Johannes Sixt wrote:\n> Consider this: You accidentally push a branch with confidential data to a\n> public repository. You notice it early, and quickly delete the branch\n> using 'git push the-repo :refs/heads/that-branch'. At this time the\n> objects with the confidential data are still lingering in the public\n> repository. But with the current behavior noone can access them even if\n> the SHA1 happens to be known.\n\nMight a repack (perhaps an automatic one) put the object in a pack\n(perhaps in a delta chain) that can be fetched through another ref?\n\n-Brad\n"},{"id":"100366","messageId":"20090114165447.qdlwqqfnk4goccgg@webmail.fussycoder.id.au","threadId":"17142","inReplyTo":"496D0E65.3000200@kitware.com","subject":"Re: How to pull remote branch with specified commit id?","fromName":"","fromEmail":"thestar@fussycoder.id.au","sentAt":"2009-01-14T05:54:47Z","receivedAt":"2009-01-14T05:54:47Z","isPatch":false,"sender":{"key":"thestar@fussycoder.id.au","avatar":null},"body":"> Johannes Sixt wrote:\n>> Consider this: You accidentally push a branch with confidential data to a\n>> public repository. You notice it early, and quickly delete the branch\n>> using 'git push the-repo :refs/heads/that-branch'. At this time the\n>> objects with the confidential data are still lingering in the public\n>> repository. But with the current behavior noone can access them even if\n>> the SHA1 happens to be known.\n\nDoesn't this line of reasoning only apply to the ssh and git transports?\n  (ie, the file and rsync transport would retrieve it regardless)\n"},{"id":"100370","messageId":"496D8DC4.1060904@viscovery.net","threadId":"17142","inReplyTo":"496D0E65.3000200@kitware.com","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-01-14T07:01:24Z","receivedAt":"2009-01-14T07:01:24Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Brad King schrieb:\n> Johannes Sixt wrote:\n>> Consider this: You accidentally push a branch with confidential data to a\n>> public repository. You notice it early, and quickly delete the branch\n>> using 'git push the-repo :refs/heads/that-branch'. At this time the\n>> objects with the confidential data are still lingering in the public\n>> repository. But with the current behavior noone can access them even if\n>> the SHA1 happens to be known.\n> \n> Might a repack (perhaps an automatic one) put the object in a pack\n> (perhaps in a delta chain) that can be fetched through another ref?\n\nNo, assuming that-branch was the only ref that contained the objects.\n\nEven if the repack happens before the branch is deleted, the objects that\nwere *only* in that-branch will not be sent out.\n\n-- Hannes\n"},{"id":"100371","messageId":"496D8E0C.5060701@viscovery.net","threadId":"17142","inReplyTo":"20090114165447.qdlwqqfnk4goccgg@webmail.fussycoder.id.au","subject":"Re: How to pull remote branch with specified commit id?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-01-14T07:02:36Z","receivedAt":"2009-01-14T07:02:36Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"thestar@fussycoder.id.au schrieb:\n>> Johannes Sixt wrote:\n>>> Consider this: You accidentally push a branch with confidential data\n>>> to a\n>>> public repository. You notice it early, and quickly delete the branch\n>>> using 'git push the-repo :refs/heads/that-branch'. At this time the\n>>> objects with the confidential data are still lingering in the public\n>>> repository. But with the current behavior noone can access them even if\n>>> the SHA1 happens to be known.\n> \n> Doesn't this line of reasoning only apply to the ssh and git transports?\n>  (ie, the file and rsync transport would retrieve it regardless)\n\nYou are right. Http and rsync would happily ship the object.\n\n-- Hannes\n"}]}