How can I see on which branch I was beforeIs there any way to git checkout previous branch?Undoing a git rebaseHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?Find and restore a deleted file in a Git repositoryHow do I show the changes which have been staged?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I push a new local branch to a remote Git repository and track it too?How do I rename a local Git branch?Git fetch remote branch
Is there a tool to measure the "maturity" of a code in Git?
How would you control supersoldiers in a late iron-age society?
The Planck constant for mathematicians
Bit one of the Intel 8080's Flags register
Are there any “Third Order” acronyms used in space exploration?
How to write characters doing illogical things in a believable way?
Why the car dealer is insisting on loan instead of cash
Output a Super Mario Image
Parallel resistance in electric circuits
Python web-scraper to download table of transistor counts from Wikipedia
Is there any reason to concentrate on the Thunderous Smite spell after using its effects?
Telling my mother that I have anorexia without panicking her
What was the motivation for the invention of electric pianos?
Why don't airports use arresting gears to recover energy from landing passenger planes?
Does my opponent need to prove his creature has morph?
Can I fix my boots by gluing the soles back on?
If I want an interpretable model, are there methods other than Linear Regression?
How To Make Earth's Oceans as Brackish as Lyr's
I was promised a work PC but still awaiting approval 3 months later so using my own laptop - Is it fair to ask employer for laptop insurance?
Fasteners for securing cabinets together
Why is the year in this ISO timestamp not 2019?
How do I say "quirky" in German without sounding derogatory?
How to publish superseding results without creating enemies
Reading double values from a text file
How can I see on which branch I was before
Is there any way to git checkout previous branch?Undoing a git rebaseHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?Find and restore a deleted file in a Git repositoryHow do I show the changes which have been staged?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I push a new local branch to a remote Git repository and track it too?How do I rename a local Git branch?Git fetch remote branch
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How can I know which branch I was previously on? More precisely, which branch git checkout -
will go to?
I would also like to know what more previous branches were, in case the previous one is not the one I want to checkout.
In other words, how to see the 'branch' history? Not the current branch commit history, but the history of branches I checked out.
All I find in my searches are about commit history.
git
add a comment
|
How can I know which branch I was previously on? More precisely, which branch git checkout -
will go to?
I would also like to know what more previous branches were, in case the previous one is not the one I want to checkout.
In other words, how to see the 'branch' history? Not the current branch commit history, but the history of branches I checked out.
All I find in my searches are about commit history.
git
Related question that explains aboutgit checkout -
:
– RSinohara
Mar 28 at 11:11
3
I would think the reflog has that info. It shows stuff likeHEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12
add a comment
|
How can I know which branch I was previously on? More precisely, which branch git checkout -
will go to?
I would also like to know what more previous branches were, in case the previous one is not the one I want to checkout.
In other words, how to see the 'branch' history? Not the current branch commit history, but the history of branches I checked out.
All I find in my searches are about commit history.
git
How can I know which branch I was previously on? More precisely, which branch git checkout -
will go to?
I would also like to know what more previous branches were, in case the previous one is not the one I want to checkout.
In other words, how to see the 'branch' history? Not the current branch commit history, but the history of branches I checked out.
All I find in my searches are about commit history.
git
git
asked Mar 28 at 11:07
RSinoharaRSinohara
3892 silver badges18 bronze badges
3892 silver badges18 bronze badges
Related question that explains aboutgit checkout -
:
– RSinohara
Mar 28 at 11:11
3
I would think the reflog has that info. It shows stuff likeHEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12
add a comment
|
Related question that explains aboutgit checkout -
:
– RSinohara
Mar 28 at 11:11
3
I would think the reflog has that info. It shows stuff likeHEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12
Related question that explains about
git checkout -
:– RSinohara
Mar 28 at 11:11
Related question that explains about
git checkout -
:– RSinohara
Mar 28 at 11:11
3
3
I would think the reflog has that info. It shows stuff like
HEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
I would think the reflog has that info. It shows stuff like
HEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12
add a comment
|
2 Answers
2
active
oldest
votes
The preferred method is to use the simple syntax @-1
(thanks @phd).
git show --decorate -s @-1
Original answer:
The reflog does seem to keep a history of where HEAD
is moved, and looks to be accessible by the HEAD@#
variable.
This however does also include resets, rebases, cherry-picks, and commits. I assume that this is because all of those commands move the HEAD
.
104f63b (HEAD -> master, master.bak) HEAD@0: checkout: moving from b2 to master
e97431a (b2) HEAD@1: checkout: moving from b1 to b2
588aa76 (b1) HEAD@2: cherry-pick: C6
befdf09 HEAD@3: reset: moving to befdf09b
80cf3dd HEAD@4: checkout: moving from master to b1
104f63b (HEAD -> master, master.bak) HEAD@5: checkout: moving from b2 to master
e97431a (b2) HEAD@6: cherry-pick: C7
befdf09 HEAD@7: reset: moving to befdf09b
4dd1828 HEAD@8: checkout: moving from master to b2
104f63b (HEAD -> master, master.bak) HEAD@9: commit: C5
be1bfdb HEAD@10: commit: C4
07743f7 HEAD@11: commit: C3
befdf09 HEAD@12: checkout: moving from b1 to master
80cf3dd HEAD@13: commit: C6
4dd1828 HEAD@14: checkout: moving from b2 to b1
4dd1828 HEAD@15: commit: C7
befdf09 HEAD@16: checkout: moving from master to b2
befdf09 HEAD@17: commit: C2
464acc2 HEAD@18: commit (initial): C1
If checking the reflog is too much there is a program to help with that.
1
Very simple syntax@-1
:git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.
– jsageryd
Mar 28 at 19:52
add a comment
|
just type history
. It will give you all the previous commands you typed in your shell.
history | grep checkout
would be an upgrade, but still, I guess reflog /@-n
is hard to surpass.
– RomainValeri
Mar 28 at 11:29
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/4.0/"u003ecc by-sa 4.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%2fstackoverflow.com%2fquestions%2f55396048%2fhow-can-i-see-on-which-branch-i-was-before%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The preferred method is to use the simple syntax @-1
(thanks @phd).
git show --decorate -s @-1
Original answer:
The reflog does seem to keep a history of where HEAD
is moved, and looks to be accessible by the HEAD@#
variable.
This however does also include resets, rebases, cherry-picks, and commits. I assume that this is because all of those commands move the HEAD
.
104f63b (HEAD -> master, master.bak) HEAD@0: checkout: moving from b2 to master
e97431a (b2) HEAD@1: checkout: moving from b1 to b2
588aa76 (b1) HEAD@2: cherry-pick: C6
befdf09 HEAD@3: reset: moving to befdf09b
80cf3dd HEAD@4: checkout: moving from master to b1
104f63b (HEAD -> master, master.bak) HEAD@5: checkout: moving from b2 to master
e97431a (b2) HEAD@6: cherry-pick: C7
befdf09 HEAD@7: reset: moving to befdf09b
4dd1828 HEAD@8: checkout: moving from master to b2
104f63b (HEAD -> master, master.bak) HEAD@9: commit: C5
be1bfdb HEAD@10: commit: C4
07743f7 HEAD@11: commit: C3
befdf09 HEAD@12: checkout: moving from b1 to master
80cf3dd HEAD@13: commit: C6
4dd1828 HEAD@14: checkout: moving from b2 to b1
4dd1828 HEAD@15: commit: C7
befdf09 HEAD@16: checkout: moving from master to b2
befdf09 HEAD@17: commit: C2
464acc2 HEAD@18: commit (initial): C1
If checking the reflog is too much there is a program to help with that.
1
Very simple syntax@-1
:git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.
– jsageryd
Mar 28 at 19:52
add a comment
|
The preferred method is to use the simple syntax @-1
(thanks @phd).
git show --decorate -s @-1
Original answer:
The reflog does seem to keep a history of where HEAD
is moved, and looks to be accessible by the HEAD@#
variable.
This however does also include resets, rebases, cherry-picks, and commits. I assume that this is because all of those commands move the HEAD
.
104f63b (HEAD -> master, master.bak) HEAD@0: checkout: moving from b2 to master
e97431a (b2) HEAD@1: checkout: moving from b1 to b2
588aa76 (b1) HEAD@2: cherry-pick: C6
befdf09 HEAD@3: reset: moving to befdf09b
80cf3dd HEAD@4: checkout: moving from master to b1
104f63b (HEAD -> master, master.bak) HEAD@5: checkout: moving from b2 to master
e97431a (b2) HEAD@6: cherry-pick: C7
befdf09 HEAD@7: reset: moving to befdf09b
4dd1828 HEAD@8: checkout: moving from master to b2
104f63b (HEAD -> master, master.bak) HEAD@9: commit: C5
be1bfdb HEAD@10: commit: C4
07743f7 HEAD@11: commit: C3
befdf09 HEAD@12: checkout: moving from b1 to master
80cf3dd HEAD@13: commit: C6
4dd1828 HEAD@14: checkout: moving from b2 to b1
4dd1828 HEAD@15: commit: C7
befdf09 HEAD@16: checkout: moving from master to b2
befdf09 HEAD@17: commit: C2
464acc2 HEAD@18: commit (initial): C1
If checking the reflog is too much there is a program to help with that.
1
Very simple syntax@-1
:git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.
– jsageryd
Mar 28 at 19:52
add a comment
|
The preferred method is to use the simple syntax @-1
(thanks @phd).
git show --decorate -s @-1
Original answer:
The reflog does seem to keep a history of where HEAD
is moved, and looks to be accessible by the HEAD@#
variable.
This however does also include resets, rebases, cherry-picks, and commits. I assume that this is because all of those commands move the HEAD
.
104f63b (HEAD -> master, master.bak) HEAD@0: checkout: moving from b2 to master
e97431a (b2) HEAD@1: checkout: moving from b1 to b2
588aa76 (b1) HEAD@2: cherry-pick: C6
befdf09 HEAD@3: reset: moving to befdf09b
80cf3dd HEAD@4: checkout: moving from master to b1
104f63b (HEAD -> master, master.bak) HEAD@5: checkout: moving from b2 to master
e97431a (b2) HEAD@6: cherry-pick: C7
befdf09 HEAD@7: reset: moving to befdf09b
4dd1828 HEAD@8: checkout: moving from master to b2
104f63b (HEAD -> master, master.bak) HEAD@9: commit: C5
be1bfdb HEAD@10: commit: C4
07743f7 HEAD@11: commit: C3
befdf09 HEAD@12: checkout: moving from b1 to master
80cf3dd HEAD@13: commit: C6
4dd1828 HEAD@14: checkout: moving from b2 to b1
4dd1828 HEAD@15: commit: C7
befdf09 HEAD@16: checkout: moving from master to b2
befdf09 HEAD@17: commit: C2
464acc2 HEAD@18: commit (initial): C1
If checking the reflog is too much there is a program to help with that.
The preferred method is to use the simple syntax @-1
(thanks @phd).
git show --decorate -s @-1
Original answer:
The reflog does seem to keep a history of where HEAD
is moved, and looks to be accessible by the HEAD@#
variable.
This however does also include resets, rebases, cherry-picks, and commits. I assume that this is because all of those commands move the HEAD
.
104f63b (HEAD -> master, master.bak) HEAD@0: checkout: moving from b2 to master
e97431a (b2) HEAD@1: checkout: moving from b1 to b2
588aa76 (b1) HEAD@2: cherry-pick: C6
befdf09 HEAD@3: reset: moving to befdf09b
80cf3dd HEAD@4: checkout: moving from master to b1
104f63b (HEAD -> master, master.bak) HEAD@5: checkout: moving from b2 to master
e97431a (b2) HEAD@6: cherry-pick: C7
befdf09 HEAD@7: reset: moving to befdf09b
4dd1828 HEAD@8: checkout: moving from master to b2
104f63b (HEAD -> master, master.bak) HEAD@9: commit: C5
be1bfdb HEAD@10: commit: C4
07743f7 HEAD@11: commit: C3
befdf09 HEAD@12: checkout: moving from b1 to master
80cf3dd HEAD@13: commit: C6
4dd1828 HEAD@14: checkout: moving from b2 to b1
4dd1828 HEAD@15: commit: C7
befdf09 HEAD@16: checkout: moving from master to b2
befdf09 HEAD@17: commit: C2
464acc2 HEAD@18: commit (initial): C1
If checking the reflog is too much there is a program to help with that.
edited Mar 28 at 13:55
answered Mar 28 at 11:38
evolutionxboxevolutionxbox
1,7482 gold badges23 silver badges34 bronze badges
1,7482 gold badges23 silver badges34 bronze badges
1
Very simple syntax@-1
:git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.
– jsageryd
Mar 28 at 19:52
add a comment
|
1
Very simple syntax@-1
:git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.
– jsageryd
Mar 28 at 19:52
1
1
Very simple syntax
@-1
: git show --decorate -s @-1
– phd
Mar 28 at 13:46
Very simple syntax
@-1
: git show --decorate -s @-1
– phd
Mar 28 at 13:46
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
@phd thanks for pointing that out.
– evolutionxbox
Mar 28 at 13:55
1
1
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.– jsageryd
Mar 28 at 19:52
git rev-parse --abbrev-ref @-1
is another variant. More info at man git-rev-parse.– jsageryd
Mar 28 at 19:52
add a comment
|
just type history
. It will give you all the previous commands you typed in your shell.
history | grep checkout
would be an upgrade, but still, I guess reflog /@-n
is hard to surpass.
– RomainValeri
Mar 28 at 11:29
add a comment
|
just type history
. It will give you all the previous commands you typed in your shell.
history | grep checkout
would be an upgrade, but still, I guess reflog /@-n
is hard to surpass.
– RomainValeri
Mar 28 at 11:29
add a comment
|
just type history
. It will give you all the previous commands you typed in your shell.
just type history
. It will give you all the previous commands you typed in your shell.
answered Mar 28 at 11:24
Srinidhi GsSrinidhi Gs
604 bronze badges
604 bronze badges
history | grep checkout
would be an upgrade, but still, I guess reflog /@-n
is hard to surpass.
– RomainValeri
Mar 28 at 11:29
add a comment
|
history | grep checkout
would be an upgrade, but still, I guess reflog /@-n
is hard to surpass.
– RomainValeri
Mar 28 at 11:29
history | grep checkout
would be an upgrade, but still, I guess reflog / @-n
is hard to surpass.– RomainValeri
Mar 28 at 11:29
history | grep checkout
would be an upgrade, but still, I guess reflog / @-n
is hard to surpass.– RomainValeri
Mar 28 at 11:29
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f55396048%2fhow-can-i-see-on-which-branch-i-was-before%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
Related question that explains about
git checkout -
:– RSinohara
Mar 28 at 11:11
3
I would think the reflog has that info. It shows stuff like
HEAD@4: checkout: blah
– evolutionxbox
Mar 28 at 11:11
It could be, my understanding is that it would go up the current branch commit history, but I realise there is no basis for my assumption
– RSinohara
Mar 28 at 11:12
Absolutely right @evolutionxbox. You can make it an answer, that is totally what I needed. Bonus points for fixing my wrong assumptions about reflog.
– RSinohara
Mar 28 at 11:12