git check origin – find the name and url of the remote server You will then see the remote name of any servers. If you don’t know what the name is of your remote is then you can use this command to check : git remote Working with remotes – add / remove / details Check the remote servers (or find git origin) Once you’ve done this you will be able to push your changes from the local repo to the remote. This connects the local repo to a remote repo at the address you specified. So to set the ORIGIN in git, the full command would be: git remote add ORIGIN There are 2 arguments to the git remote add command: In this case you will need git set-url as described below. If there is already a remote with the name specified, you will get an error when you use the git remote add command. You use the git remote add command when there is not already a remote with the name specified. Set the remote repository using git remote add If you had renamed your remote to MYREMOTE then you would have to type: git fetch MYREMOTE In that case, all of these commands do exactly the same thing : git fetch ORIGIN In many cases you don’t have to specify ORIGIN because it’s presumed that it’s the name of your remote. It’s important to understand that in many git commands certain details are presumed. When you start out using git it can feel as if the only time you see mention of ORIGIN is when you see an error. If you haven’t deliberately changed anything about the remote – or if you have no idea what that even means, then you can presume that you have one remote, and that it’s called ORIGIN. So if you don’t tell it what you want your remote to be called, then it will call it ORIGIN by default. When you initially clone a repository using git clone, it automatically creates a remote connection called ORIGIN pointing back to the cloned repository. ORIGIN is just a shorthand name for the url of a remote repository. If you were to run the command git remote add origin and then command git remote add ORIGIN you will have two new remotes, one called origin and one called ORIGIN! Git is case sensitive so it is fairly easy to accidentally create multiple remotes. However it’s good to know how to add and remove a git remote. One repository can have multiple ‘remotes’ – although most generally you will only have one. Once created, the repository has a unique url – the url of this remote repository that I’ve created is: Here is a screenshot of what it looks like when you create a new repo in github. Create the remote repo in githubīefore you can do anything else you need to make sure the remote url exists in your github account, and for that to be the case you need to create a new repository. The remote repo can then be cloned by others so they can also contribute to the code in the repo. You need to set up an account with github / gitlab / bitbucket which are some of the many hosts of remote repositories. So if you change your local files, the remote ones won’t change until you ‘commit’ your local changes and ‘push’ them to the remote repo. Once you push your files from your local repo to your remote repo it means there is a copy of them in a remote location.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |