Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

git can I view the reflog of a remote?

Is it possible to view the reflog of a remote? That is, I want to know what the output of git reflog is on another remote machine.

Note, I am not asking for the reflog of remote-tracking branches (such as origin/master), I am asking for what reflog says on the other machine.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On the off chance that the remote machine is a github repository,

  1. First use Github’s Events API to retrieve the commit SHA.
    curl https://api.github.com/repos/<user>/<repo>/events

  2. Identify the SHA of the orphan commit-id that no longer exists in any branch.

  3. Next, use Github’s Refs API to create a new branch pointing to the orphan commit.

    curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"ref":"refs/heads/D-commit", "sha":"<orphan-commit-id>"}' https://api.github.com/repos/<user>/<repo>/git/refs

    Replace <orphan-commit-id> in the above command with the SHA identified in step 2.

  4. Finally git fetch the newly created branch into your local repository.
    From there you can cherry-pick or merge the commit(s) back into your work.

Check out this article for an actual example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...