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. Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch. 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. The easiest way is just to use the git branch commands’ various options. 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 |