♠ Posted by NN TRUNG at 18:12
Return to posts created repository , I can teach you how to create a repository on Github service and clone it to your computer. Thus, the Github repository is a remote server, so I'll call it the Remote Repository, this means that the repository is not on your computer.
And in that section, you may find yourself calling the data you send to the repository by using the command
git push origin master
after not commit? Cai master
branch is that his name will not be mentioned in this article, but the origin
of this paragraph is called remote repository. Default when clone a repository, it can call itself origin
.
To check the name of the remote, you can type the command
git remote -v
.$ Git remote -v https://github.com/thachphamblog/hoc-git.git origin (fetch) https://github.com/thachphamblog/hoc-git.git origin (push)
In it you can see what you have clone repository is named
origin
, and each repository you two are two actions that fetch (retrieve data from the server) and push (send data to the server).
Looking back at the command paragraph
git push origin master
above, it means that you send all the changes on your source code up remote machine named origin
with branch master
.Rename remote
If you do not like the name of
origin
, you can rename it back it by a different name for easy management of multiple remote if you have a project with the commandgit remote rename tên_cũ tên_mới
. For example I need to change from origin
to thach
will change as follows:$ Git remote rename origin thach $ Git remote -v thach https://github.com/thachphamblog/hoc-git.git (fetch) thach https://github.com/thachphamblog/hoc-git.git (push)
Now that commit or push you can type
git push thach master
to send the code to a remote repository this.Add a remote
In case you need to add a remote to retrieve the data when necessary, can use the
git remote add tên_remote URL
. For example you need a remote repository and Inuit name it would read:$ Git remote add unuit https://github.com/thachpham92/inuit.css-web-template $ Git remote -v thach https://github.com/thachphamblog/hoc-git (fetch) thach https://github.com/thachphamblog/hoc-git (push) Inuit https://github.com/thachpham92/inuit.css-web-template (fetch) Inuit https://github.com/thachpham92/inuit.css-web-template (push)
Then if you want to get data from the
inuit
on the other end just use the command git fetch inuit
.$ Git fetch Inuit warning: no common commits remote: Counting objects: 94, done. remote: Total 94 (delta 0), reused 0 (delta 0), pack Unpacking objects: 100% (94/94), done. From https://github.com/thachpham92/inuit.css-web-te * [New branch] master -> Inuit / master
Note that the command
git fetch
it only took about and saved to the Git database and not be included in your repository. To subsumed you can by typing git merge inuit
, including inuit
are remote names.
And if you want it to take on directly without the use gross orders
git pull tên_remote
, but you yourself encourage subsumed branch as needed and be careful in the aggregate, it is best to create a new folder in the mail Then position your work in that fetch.
The difference between clone
, fetch
and pull
Maybe now you know three commands to retrieve data from that repository git clone git fetch and git pull.But all three are taking data, so the difference of what it is?
git clone
This command will copy the entire data repository and copy the settings always repository, that is, it automatically creates a master branch on your computer. This command should only be used when you need to create a new Git on the computer with all the data and settings of a remote repository.
git pull
This command will automatically retrieve all data from remote repositories and included in the current branch you are working.
git fetch
This command will retrieve all data from remote repository, but will allow you to include craft into a certain branch on Git in computer folders.
Temporarily you should understand that, in all the branch you will understand more.
The protocol type of the Remote Repository
We not only connect with a remote repository via HTTP or HTTPS protocols, but also can choose multiple protocols, here are a few remote repository protocol.
Local Repository
This protocol means that you connect to a specific repository on your own computer and URL protocols will form
/path/repository/
.HTTP Repository
The most common protocol and readily understood, is often used if you use remote services like Github repository or Assembla, it will include formatting
http://domain.com/repository.git
orhttps://domain.com/repository.git.
SSH Repository
This protocol is commonly used on the server needs to create a separate repository and connect through SSH protocol. The path of this protocol will have the format
user@server:/path/repository.git
. At the end of his series will teach you how to create a separate repository server and it was very good choice if you work without group depend on services like Github or Assembla.Epilogue
In this article you will probably be able to see how Git flexibility by allowing you to retrieve data from a remote repository or multiple repositories differently. On the other hand, I also want answers to the origin you have any questions on what the statement is because in future articles I will also use plenty of statements contained in it anymore origin.
0 nhận xét:
Đăng nhận xét