On some development branches I need to use origin/master on others I need to use origin/dev. I want to use some scripts to automate my work a little more, and I would like to know how to determine the origin string to use without having to pass it in as a parameter or have it set as an environment variable.
Using 'git remote show origin' gives me a bunch of output with the information I need near the end. It says:
Local branch configured for 'git pull': mybranch merges with remote dev
Is there some way to do this without having to parse through all of the output for 'git remote show origin'?
git branch -vv
will give you a list of your local branches: name, current commit sha, and then in square brackets the name of the remote branch they're tracking (if any). You should be able to use that easily to find out what you need.
Note that the active (currently checked out) branch is hilighted with a leading asterist (*).
You can additionally limit the list by using git branch -vv --list <pattern>
where <pattern%gt; would be the branch name you want to query (e.g. git branch -vv --list issue12
to get the info only for branch "issue12")