Get the remote name

Asked

Viewed 304 times

5

In the bash Git, to update the branch place in use from a branch remote, we use the command:

git pull nomeDoRemote nomeDoBranch

Still in the bash, when navigating to a project directory, we see something more or less like this:

usuario MINGW64 ~/foo/bar (nomeDoBranch)

That way, it’s easy to know the name of a branch to update it - with the assumption that it was created from a remote, or that at least it is published.

But how can we get the name of(s) remote(s) associated with the project?

2 answers

8


Using the command git remote -v, you will see the configured remote repositories in your local project:

marcelo@marcelo-X555LF:/var/www/html/projeto$ git remote -v
origin  https://[email protected]/repositorio/projeto.git (fetch)
origin  https://[email protected]/repositorio/projeto.git (push)

With the git ls-remote you’ll see the remote repositories associated with commits:

From https://[email protected]/repositorio/projeto.git
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        HEAD
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/dev
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/feature#10915
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/feature#12617
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/feature#14391
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/master

1

Or you can use the command git remote show:

$ git remote show
origin

Browser other questions tagged

You are not signed in. Login or sign up in order to post.