Distance learning git repository

A. Git add remote repositories

Github first have to register a user name, my github account is: [email protected]

1: github after landing in the upper right corner click the plus sign to add a warehouse

 

2: Add warehouse title name (mine is learngit) must be written, it does not matter described can add follow-up. Click to create reponsitory

3: After successfully added, we will have their own new warehouse github

 

 

II. Correlation and removing the remote repository

After creating a successful, we will see the address of the warehouse, as follows: [email protected]: 1654218052 / learngit.git, then I need to our previous local warehouse and the remote repository associated using git remote add command as follows:

$ git remote add origin [email protected]:1654218052/learngit.git

 

If you have configured wrong, do not be nervous, execute the following command to remove the remote repository configuration

$ git remote rm origin

After adding the library is the name of the remote origin, this is the default name for git, of course, it can be changed to another

 

 

III. Push the local repository to the remote content library

For the first time when the execution of all the contents of the local repository pushed to the remote repository:

$ Git push -u origin master # for the first time pushed to perform remote repository

Due to the remote library is empty, the first time we push the master branch, with the -uparameters, Git will not only master the new remote branch content push local master branch, but also to master the local branch of the master and remote branch associate at a later push or pull command can be simplified. , You do not need -u parameters, and only need to perform the following command.

$ Git push origin master # not the first time pushed to perform remote repository

If you want to push to another branch, for example, I also want my lalal branch pushed to the remote repository, execute the following command:

$ Git checkout lalal # pointing branch lalal
$ Git push down lalal branch -u origin lalal # push to a remote repository

To switch to fa branch, and then execute git push command, parameter meaning the same as before, where the name of the branch of a remote repository we created also fa (of course we can take any name, but in order not to confuse, it is best to take the same name ). After these two commands executed successfully, this time on github, we can see already have multiple branches of

 

IV. Clone a remote repository to local

First log on github, we create a new warehouse in gitskills on github.

After that, we will learn sides to a local warehouse to clone

$ Git clone my [email protected]: 1654218052 / gitskills.git
Cloning into 'gitskills'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

 

Note that the address into your own Git repository, this time we will be able to enter gitskills, obviously this is an empty warehouse it will not produce any output

$ cd gitskills
$ ls

 

 

Reading can harvest Oh appreciation

Guess you like

Origin www.cnblogs.com/xiaocainiao920/p/11653379.html