There are many commands which are useful some of them are -s It will tell you on which branch you are on You can use git bash on the working directory to write the current commit in human-readable form. If it doesn't start with 'ref: ', then it is detached HEAD (anonymous branch), pointing directly to some commit. Strip this prefix to get full name, and strip refs/heads/ to get short name of the current branch: b="$" git/HEAD is symref (symbolic reference), and we are on normal branch. This usually happens if the repository is bare. If this file doesn't exist, then there is no current branch. git/HEAD file is a symbolic link (a very rare case, from the ancient history of Git), it uses git symbolic-ref HEAD 2>/dev/nullĮlse, it reads. Git uses unnamed branch (detached HEAD) during the rebase process to make it atomic, and original branch is saved elsewhere. How git-prompt.sh from contrib/ does it (git version 2.3.0), as defined in _git_ps1 helper function:įirst, there is special case if rebase in progress is detected. Why not use git-aware shell prompt, which would tell you name of current branch? git status also helps. (FYI this was done with git version 1.8.3.1) all the other use cases: fatal: ref HEAD is not a symbolic ref.all other use cases: SHA of the corresponding commit.remote tracking branch (not in sync): remotes/origin/feature-foo.remote tracking branch (in sync): heads/master (note: not remotes/origin/master).general detached head: # HEAD detached at 285f294.remote tracking branch (not in sync): # HEAD detached at origin/feature-foo.remote tracking branch (in sync): # HEAD detached at origin/master.general detached head: (detached from 285f294).remote tracking branch (not in sync): (detached from origin/feature-foo).remote tracking branch (in sync): (detached from origin/master).general detached head (none of the above).submodule (run inside the submodule directory).remote tracking branch, not in sync with a local branch (origin/feature-foo).remote tracking branch, in sync with local branch (origin/master at same commit as master).For my own reference (but it might be useful to others) I made an overview of most (basic command line) techniques mentioned in this thread, each applied to several use cases: HEAD is (pointing at):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |