hiltdark.blogg.se

Git add remote orign
Git add remote orign









git add remote orign
  1. Git add remote orign how to#
  2. Git add remote orign code#

Since we Created a GitHub Repository in the last tutorial, in this we will try to connect it with the local repository. And then the user connects it to the remote repository.īelow we are going to go through the second approach, where a user has already a local repository and an empty remote repository, but these repositories are not linked with each other.

  • From local: This happens with the help of the Git Remote command when the repository is first created on local.
  • ( Note: We cover this in the next chapter) User makes a git fork or git clone to the same repository at local.
  • From remote: This happens with the help of the Git Fork command when the repository is already available on GitHub.
  • There are always a few ways to link the local repository to the remote repository.

    Git add remote orign how to#

    How to Link an Existing Git Local Repository to Remote Repository?

  • How to connect Local Repository with Remote Repository?.
  • Throwing some light on the subject of this post, this post will walk you through: We created an account on GitHub, now it is time that we push our local data to a remote location at GitHub. This means, whatever the data is available on Local Repository can be uploaded to Remote Repository on GitHub. There is a really helpful video 📹 that explains all of this that can be found here.As we learned in one of the previous tutorials that GitHub repository is a repository over the cloud. You can also see that both of the remote repositories have the same project name amazing-project and that gives us one reason why the remote repository names in the remote server and the shortnames in our local repositories should not be the same! In the above image you can see that I used the shortname friend to refer to my friend's remote repository. We can use the command git remote add in order to add a link to their remote repository in our local repository.

    Git add remote orign code#

    And let's assume we want to be able to fetch code from their remote repository. Suppose we have a friend who forks our remote repository so they can help us on our project.

    git add remote orign

    I will answer that question with another example. So final question, why don't we just use the same name? In many cases you will have links to multiple remote repositories in your local repository and each of those will have a different shortname. And in our example above it is called origin.īasically origin is the default shortname that Git uses for a remote repository when you clone that remote repository.

    git add remote orign

    And this shortname kind of acts like an alias for the url, it's a way for us to avoid having to use that entire long url in order to push or fetch code. It is the shortname we are going to use whenever we want to push or fetch code from that remote repository. The other name that we have for our repository is the shortname that it has in our local repository that is related to the URL of the repository. And in our case that is 'amazing-project'. This can be kind of thought like a project name.

    git add remote orign

    Well one of the names that we have for our repository is the name it has on GitHub or a remote server somewhere. So why does it seem like there are two names for the remote repository? Now, this may be a bit confusing because in GitHub (or the remote server) the project is called 'amazing-project'. There you will see that in order to push or fetch code from your remote repository you will use the shortname 'origin'. If you run the command git remote -v it will list all the remote repositories that are linked to your local repository. The remote repository and the local repository are linked. Then you would have something like what you can see in the diagram below:īecause you cloned the repository. Supposed you have a remote repository called amazing-project and then you clone that remote repository to your local machine so that you have a local repository. Therefore in order to properly answer this questions we need to understand what origin is. The rest of the links need to have different names. However only one of those links can be called origin. A local repository can be linked to multiple remote repositories.











    Git add remote orign