Mastering git, Part 2, Creating and managing repositories

Creating a bare repository

Creating a repositiy

Managing remotes

You need to know how to handle your remote repositories in order to be able to work on any  Git project. Remote repositories are copies of your project which are hosted elsewhere on the Internet or the network. You can have several of them,

Adding remote

git remote add <remote-name> <url>

git push <remote-name> <branch> explicitly says “push the local branch ‘master’ to the remote named ‘origin'”. This does not define a persistent relationship, it just executes a push this one time. Note that the remote branch is assumed to be named “master”.

Or you can use git push --set-upstream origin master (or the short version: git push -u origin master ) which is  the same thing as git push <remote-name> <branch> , except it first adds a persistent tracking relationship between your local branch “master” and the remote named “origin”. As before, it is assumed the remote branch is named “master”, later on you can just  use git push
You can add more remotes:

Viewing remotes

Renaming and Removing Remotes

Changing a remote’s URL

git remote set-url <existing-remote-name> <new-URL-for-the-remote> changes an existing remote repository URL.

Cloning

When you  clone your repository, you don’t need to run
git push -u <remote-name> <branch-name>

because origin/master is already set up as master‘s upstream branch. In other words, master is already set to track origin/master.

Checking the progress of cloning

 

 

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x