The -heads option lists only branch names since the command can list tags too. The ls-remote command returns the SHA1 hash of the latest commit for that reference, so it is quite easy to parse out and get to the exact commit you need if you’re doing some scripting. The former displays plenty of information about the remote in general and how it relates to your own repository, while the latter simply lists all references to branches and tags that it knows about. There’s also another way to do figure out what branches are on your remote by actually using the remote related commands, git remote and git ls-remote. If you have color options on it’s also quite easy to tell which branches aren’t pulled down since they’re listed in red. So, once you know the name of the branch it’s quite simple to check them out. a shows all local and remote branches, while -r shows only remote branches. git branch -list results include a, then I ran git remote prune origin which said pruned origin/a.Now git branch -list results still include a, git checkout a reported that the upstream was gone and suggested git branch -unset-upstream. Snapshot of this information is stored locally in. Reading up on this, it sounded like just what I needed but after trying it, Im not sure it was. The easiest way is just to use the git branch commands’ various options. Try to communicate to remote and get list of branches on that remote. UPDATE: The comments have enlightened me quite a bit…there seems to always be more than one way to skin a cat using Git. If you’re using GitHub or gitweb to host your repository it’s usually easy to determine the branch names, but if you need to get them in general or for scripts it’s not exactly clear. Sometimes you may need to figure out what branches exist on a remote repository so you can pull them down and check them out, merge them into your local branches, etc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |