4

I've got an old repo on my machine that I cloned some time ago, and want to know where it would push to if I ran:

git push

How can I tell where it will push to?

Brad Parks
  • 66,836
  • 64
  • 257
  • 336

2 Answers2

7

To display the URL of origin:

git config --get remote.origin.url

origin which is where git push (with no parameters) will push to. The command git remote show origin will also list branch information. The push location can be overridden if you've set branch.*.remote for the current branch.

You can also run git push --dry-run, which will show you more information about what the push will do. Also, you can manually specify the remote repo by adding it as a parameter to the push command.

AndrewS
  • 8,196
  • 5
  • 39
  • 53
  • thanks for the feedback... well the thing is i'd like this to also work for the case where I don't have anything to push - I really want to just see where the remote that it would push to is... I tried it on my repo that had no changes in it, and it responded with "Everything up-to-date" – Brad Parks Jul 31 '14 at 16:35
  • Dry-run said that? What did `git remote show origin` dump out? – AndrewS Jul 31 '14 at 16:36
  • it dumped out lots more and seems good to me too.... ```* remote origin Fetch URL: https://some-test-server/bparks/test-project.git Push URL: https://some-test-server/bparks/test-project.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master rebases onto remote master Local ref configured for 'git push': master pushes to master (up to date) ``` – Brad Parks Jul 31 '14 at 16:38
  • 1
    That **Push URL:** is where it'll push to. You can also try `git config --get remote.origin.url`, which just displays the URL and not any branch information. – AndrewS Jul 31 '14 at 16:40
2

It appears that

git remote -v

will show where it will push to....

For example, I ran it in my repo, and it showed the following:

origin  https://some_remote_server/bparks/test-project.git (fetch)
origin  https://some_remote_server/bparks/test-project.git (push)

which seems to suggest what it would push too...

Brad Parks
  • 66,836
  • 64
  • 257
  • 336