Configure remote
Last updated
Last updated
To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.
The word “remote” does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere!
To see which remote servers you have configured, you can run the git remote
command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin
— that is the default name Git gives to the server you cloned from:
Note: If you do not get any output, it means no remote servers are configured!
You can also specify -v
, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote, v
stands for verbose:
You do not have an account, create a GitHub account and then from the homepage, create a New
repository as highlighted in the below steps:
Using the commands which git is already showing, let us add and push our existing repository on to GitHub help with the below commands:
The -u
switch makes the remote GitHub repo the default for your existing project ('U' stands for upstream)
From next time we can simply specify push
without specifying origin or master!
We can also add the -f
option in the above command to force the push. Sometimes our push operation may be rejected since there may be extra files present in GitHub (like readme.md file) which is not present in our local repository:
To verify that the existing project was pushed to GitHub successfully, log into the GitHub website and browse the repository. All of the files from your existing project should be visible on GitHub’s.
So, refresh the browser and you should see the following: