Ios-git Remote Warehouse (Distributed version control system)

Source: Internet
Author: User
Tags version control system

Objective
    • A remote repository is a repository of your projects hosted on the Internet or other networks. You can have several remote warehouses, usually some of which are read-only to you, and others that you can read and write.
1. View Remote repositories
  • If you want to see the remote warehouse server you have configured, you can run the git remote command. It lists the shorthand for each remote server you specify. If you have cloned your own repository, you should at least see origin that this is the default name for the repository server that Git has cloned for you.

    $ git remote
    origin
  • You can also specify options -v that show the URL of the Git saved shorthand that needs to be read and written to the remote repository.

    $ git remote -v
    origin  https://github.com/schacon/ticgit (fetch)origin  https://github.com/schacon/ticgit (push)
    • If you have more than one remote repository, the command will list them all. For example, in collaboration with several collaborators, warehouses with multiple remote warehouses look like the following.

      $ git remote -vbakkdoor  https://github.com/bakkdoor/grit (fetch)bakkdoor  https://github.com/bakkdoor/grit (push)cho45     https://github.com/cho45/grit (fetch)cho45     https://github.com/cho45/grit (push)defunkt   https://github.com/defunkt/grit (fetch)defunkt   https://github.com/defunkt/grit (push)koke      git://github.com/koke/grit.git (fetch)koke      git://github.com/koke/grit.git (push)origin    [email protected]:mojombo/grit.git (fetch)origin    [email protected]:mojombo/grit.git (push)
  • If you want to see more information about a remote warehouse, you can use the git remote show [remote-name] command.

    # git remote show [remote-name]$ git remote show origin
    • If you want to run this command in a specific abbreviated name, such as origin, you will get a message like the one below.

      $ git remote show origin* remote origin  Fetch URL: https://github.com/schacon/ticgit  Push  URL: https://github.com/schacon/ticgit  HEAD branch: master  Remote branches:    master                               tracked    dev-branch                           tracked  Local branch configured for 'git pull':    master merges with remote master  Local ref configured for 'git push':    master pushes to master (up to date)
    • It also lists the URL of the remote repository and the information that tracks the branch. This information is very useful, it tells you that you are in the Master branch, and if you run Git pull, you crawl all the remote references and then merge the remote Master branch into the local master branch. It also lists all the remote references that were pulled to.

    • If you're a heavy user of Git, you can also git remote show see more information.

      $ git remote show origin* remote Origin url:https://github.com/my-org/complex-project Fetch url:https://github.com/my-                            Org/complex-project Push url:https://github.com/my-org/complex-project HEAD branch:master Remote branches:master     Tracked Dev-branch tracked Markdown-strip tracked  Issue-43 new (next fetch would store in Remotes/origin) issue-45 new (Next fetch would store in Remotes/origin) refs/remotes/origin/issue-11 stale (use ' git remote prune ' to remove) L Ocal branches configured for "Git Pull": dev-branch merges with remote Dev-branch Master merges with remote mast Er Local refs configured for ' git push ': Dev-branch pushes to dev-branch (up t                         o date) Markdown-strip pushes to Markdown-strip (up to date) master Pushes to Master                         (up to date) 
    • This command lists which remote branch is automatically pushed to when you execute a git push on a particular branch. It also lists which remote branches are not on your local, which remote branches have been removed from the server, and which branches are automatically merged when you execute them git pull .

2. Add a remote repository
  • Run git remote add [shortname] [url] add a new remote Git repository and specify a shorthand that you can easily reference.

    # git remote add [shortname] [url]$ git remote add pb https://github.com/paulboone/ticgit
    $ git remote -vorigin  https://github.com/schacon/ticgit (fetch)origin  https://github.com/schacon/ticgit (push)pb  https://github.com/paulboone/ticgit (fetch)pb  https://github.com/paulboone/ticgit (push)
      • Now you can use the string PB in the command line instead of the entire URL. For example, if you want to pull the information that Paul has in the repository but you don't have it, you can run it git fetch pb .

        $ git fetch pbremote: Counting objects: 43, done.remote: Compressing objects: 100% (36/36), done.remote: Total 43 (delta 10), reused 31 (delta 5)Unpacking objects: 100% (43/43), done.From https://github.com/paulboone/ticgit * [new branch]      master     -> pb/master * [new branch]      ticgit     -> pb/ticgit
      • Now Paul's master branch can be accessed locally through pb/master-you can merge it into one of your own branches, or you can check out a local branch that points to that point if you want to see it.

3. Crawling from remote warehouses
    • Data is obtained from the remote repository and can be executed git fetch [remote-name] . This command accesses the remote repository and pulls all the data you don't have.

      # git fetch [remote-name]    $ git fetch origin
      • Once executed, you will have a reference to all the branches in that remote repository and can be merged or viewed at any time.
      • It is important to note that the git fetch command pulls the data to your local repository, it does not automatically merge or modify your current work, and you must manually merge it into your work when you are ready.
      • If you clone a repository using the Clone command, the command automatically adds it as a remote repository and defaults to "origin". So, git fetch origin it crawls all the work that was pushed after the clone (or the last crawl).
4. Pull from the remote repository
    • If you have a branch set up to keep track of a remote branch, you can use git pull the command to pull the crawl and then merge the remote branch into the current branch.

      $ git pull
      • Running git pull typically fetches data from the server that was originally cloned and automatically attempts to merge into the current branch.
      • By default, the git clone command automatically sets the local master branch to track the master branch of the cloned remote repository (or whatever name is the default branch).
5. Push to remote Warehouse
    • When you want to share your project, you have to push it upstream. This command is simple: git push [remote-name] [branch-name] . When you want to push the master branch to the origin server (again, the two names are usually set automatically when cloning), run this command to backup your backups to the server

      # git push [remote-name] [branch-name]$ git push origin master
      • This command will only take effect if you have write access to the clone server and no one has been pushed out of date before.
    • When you clone with other people at the same time, they push it upstream and then you push it upstream, and your push will undoubtedly be rejected. You must first pull down their work and merge it into your work before you can push it.

6. Renaming a remote repository
    • If you want to rename the referenced name, you can run git remote rename to modify the shorthand name of a remote repository.

      # git remote rename [old-shortname] [new-shortname]$ git remote rename pb paul
      • For example, to rename a PB to Paul, you can do this with git remote rename.

        $ git remote rename pb paul$ git remoteoriginpaul
      • It is important to note that this will also modify the name of your remote branch. Those who used to cite Pb/master will now cite Paul/master.

7, remote warehouse removal
    • If you want to remove a remote repository for some reason, you can use it git remote rm .

      # git remote rm [shortname]$ git remote rm paul
      $ git remoteorigin

Ios-git Remote Warehouse (Distributed version control system)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.