Git commands - Remote Operations

Git commands remote operation are:

  1. Remote git $                                               # Remote Server
  2. Git Remote -v $                                                # View remote repository information
  3. Remote Show git $ [Remote-name]                # view the information specified remote repository
  4. Remote git the Add $ <Short-name> <url>          # to add a remote repository
  5. FETCH git $ [Remote-name]                             # fetch data from a remote repository
  6. Git pull $ <Remote-name> <Branch-name>  # pull data from a remote repository merging the current branch
  7. Git the Push $ [Remote-name] [Branch-name]   # push local data to a remote warehouse
  8. Remote git the rename $ <Old> <new new>               # modify a remote repository reference name
  9. Git Remote RM $ < Short-name >                     # Removes the specified remote repository

 

1. Check the remote repository

If you want to view the remote repository server you have configured, you can run the git remote command. It lists short each remote server you specify. If you have been cloned own warehouse, then at least it should be able to see origin - that is to Git repository server you cloned the default name:

 

You can also run git Remote -v , it will show the need to read and write using Git remote repository shorthand to save its corresponding URL.

 

If you have more than one remote repository, the command will list them all. For example, in collaboration with several collaborators, with multiple remote warehouse warehouse looks like this:

So that we can easily pull any contribution which a user.

 

If you want to see more information on a remote repository, you can use the git remote show [remote-name] command. If you want to run this command to a specific short name, such as origin, you will get similar information like the following:


 

2. Add a remote repository

Run git remote add <short-name> <url> command to add a new remote Git repository, you can easily specify a shorthand references:

 

Now you can use the command line string pb instead of the entire URL. For example, if you want to pull Paul's in stock but you do not believe interest rates can run git FETCH pb :

 

3. pull from a remote repository

Obtaining data from a remote repository, you can execute the command:

$ git fetch [remote-name]

This command accessing a remote repository, pull data from all of you have not. After the execution is complete, you will have to refer to all branches of the remote repository, you can merge or view at any time. Note : git fetch command will pull data to your local repository - it does not automatically merge or modify your current job. When you are ready you must manually merge them into your work.

4. pull data from a remote repository merging the current branch

Run git pull usually crawls all branches modified data originally cloned from the server and automatically attempts to modify the corresponding branch merged into the current branch. If you want to get updates designated branches and close it into the current branch, execute the following command:

$ git pull <remote-name> <branch-name> 

 

The push data to a remote repository local

When you want to share your project, it must be pushed to the upstream. This command is very simple: git the Push [Remote-name] [Branch-name] . When you want to push your master branch to the origin server so you can run this command to back up what you do to the server:

Only when you have written permission to clone servers, and no man before pushing obsolete, this command can take effect. When you clone and others at the same time, they are pushed to the first upstream and then you and push to the upstream, your push will undoubtedly be rejected. You must first pull down their work and incorporate it into your work in order to push back.


6. Remove and re-naming of a remote repository

If you want to rename a reference names can run git remote rename to modify the abbreviated name of a remote warehouse. For example, you want to pb renamed to paul , you can use git remote rename to do so:

 

如果因为一些原因想要移除一个远程仓库 - 你已经从服务器上搬走了或不再想使用某一个特定的镜像了,又或者某一个贡献者不再贡献了,可以使用 git remote rm 命令:

 

Guess you like

Origin www.cnblogs.com/shichangxing/p/11442139.html