GitHub User's manual-basic article

Source: Internet
Author: User
Tags hosting version control system git commands ruby on rails

Origin

Git has become one of the programmer's skills, and GitHub is a popular git repository hosting platform that not only provides git repository hosting, but also a great technical social platform that can be collaborated and communicated through open source projects, and is now well-practiced by good engineers.

This set of tutorials starts with the history of GitHub, introducing Git installation, creating warehouses, Fork, socialization, command-line development, and the use of graphical tools at the end.

By completing this tutorial, you will not only master the GitHub command line usage, but also learn how to use it graphically.

About GitHub

Git is an excellent distributed version control system. The version control system can keep a history of a collection of files and can roll back a collection of files to another State (history state). Another state can be a different file, or it can be a different file content. In a distributed version control system, everyone has a complete source code (including all the history information from the source) and can operate on the local data. Distributed version control systems do not require a centralized code warehouse.

GitHub is a managed platform for open source and private software projects because Git is hosted only as a unique repository format, so it's called GitHub.

GitHub was launched on April 10, 2008, with features such as subscriptions, discussion groups, text rendering, online file editors, collaboration maps (reports), Code Snippets Sharing (Gist), in addition to Git code warehouse hosting and basic WEB management interfaces. Currently, its registered users are more than million, the number of managed version is also very much, including many well-known open source project Ruby on Rails, JQuery and so on.

GitHub Advantage

The advantage of GitHub's popularity is that it cannot be overlooked:

  1. GitHub only supports Git-formatted repository hosting, unlike other open-source project hosting platforms, which are also hosted in CVS, SVN, Hg, and other format repositories. The philosophy of GitHub is simple, since git is one of the best version control systems (not one for many people like Git and GitHub), there's no need to sacrifice some of Git's unique features to take care of other version control systems. So there is no historical burden to support other version control systems, one of the elements of GitHub's success.

  2. GitHub provides full protocol support for the Git repository, which supports HTTP smart protocols, Git-daemon, and SSH protocols.

  3. GitHub provides the ability to edit files online, and users who are unfamiliar with Git can also modify the files in the repository directly from the browser.

  4. Bringing social networks into the project hosting platform is a feat of GitHub. Users can follow projects, follow other users, and learn about project and developer Dynamics.

  5. The project's Fork and pull Request form the most unique mode of work for GitHub. The progressive commentary on the submitted code and pull Request constitute a GitHub-specific code review.

  6. GitHub has been commercially successful through private repository hosting, enterprise-oriented repository hosting and project management platforms, recruitment and other paid services that allow GitHub to maintain operations without having to embed ads on the page, the biggest beneficiaries or users.

  7. Using the Ruby on Rails architecture, the GitHub website uses a large number of JavaScript, AJAX, HTML5 and other technologies in WEB design to support rendering and display of content in markup languages such as Markdown. Attention to detail makes GitHub a rising star in the field of project hosting. GitHub Registration

    The first step to using GitHub is, of course, registering a GitHub account:

    1, first open https://github.com/pricing to register.

    2. In the open page, click "sign up now" Registration, 1.1 shows.


    Figure 1.1

    3, create the user name in the next page, fill in the email and set the password, click "create an account" button to create an account, 1.2.


    Figure 1.2

    4, select the account type, here we default to select "Free" type, click "finish Sign up" button to complete the registration, 1.3.


    Figure 1.3

    Note: Depending on our needs, different types of choices are hosted free of charge if the open source project is stored, and a private library is required. The fees are as follows:

    Private Library Space Fees number of private libraries
    Big $50/Month 50
    In $20/Month 20
    Small $10/Month 10
    Tiny $5/Month 5
    Free $0/Month 0
    Install Git

    1. Download and install the latest version of Git.

    2. After the installation is complete, open the Terminal command (for Apple system users) or command prompt (for Windows and Linux users).

    3. Tell Git your name so that your submission can be correctly tagged. $after entering the following content:

    $ git config --global user.name "YOUR NAME"

    4. Tell the GIT email address to associate with your git commit. The mailbox you specify is the same as the one in the mailbox settings. How to keep your email address hidden, please refer to: Keep your email address private.

    $ git config --global user.email "YOUR EMAIL ADDRESS"
    Verify GitHub with Git

    When you connect to a GitHub repository via Git, we need to validate GitHub, there are two ways to verify this:

      • Authentication over HTTPS
      • Authentication via SSH
    Establishing a connection over HTTPS (recommended)

    If you choose HTTPS Mode, we can use a certificate helper to cache the GitHub password in Git.

    Connect via SSH

    If you choose SSH, we need to generate SSH keys on the computer to push or pull from GitHub.

    Create a new warehouse on GitHub

    1. In the top right corner of any page, click +, then click New Repository.

    2. Create a short, easy-to-remember name for your warehouse. For example, "Hello-world".

    3. Add a description (not required) for your warehouse. For example, "My first repository on GitHub".

    4. Choose your warehouse type as public or private:

      • Public: A common repository is a good choice for beginners who are just getting started. These warehouses are visible to everyone on GitHub and you can benefit from a collaborative community.
      • Private: More steps are required for a privately owned warehouse. They are only available to you, and the owner of this repository belongs to you and the collaborators you designate to share. Private warehouses are only available for paid accounts. For more information, please refer to "What plan should I choose?".

    5. Select Initialize this repository with a README.

    6, click Create Repository.

    Congratulations! You have successfully created your first warehouse and initialized it with a README file.

    Submit your first change

    A commit is like a snapshot of a file in your project at a specific point in time.

    When you create a new repository, you initialize it with a README file. The README file has a detailed explanation of your project, or adds some documentation on how to install or use the project. The contents of the README file are automatically displayed on the home page of your warehouse.

    Let's submit a change to the README file.

    1, in your warehouse file list, click Readme.md.

    2. Above the contents of the file, click the Edit button.

    3. On the Edit File tab, enter some information about yourself.

    4. Above the new content, click on Preview changes.

    5, check your changes to this file, you will see the new content is marked with green.

    6. At the bottom of the page, under "Commit changes", enter some short, meaningful submissions to explain the changes you made to this file.

    7. Click Commit Changes.

    Fork a sample Warehouse

    Fork is a clone of a warehouse. Cloning a warehouse allows you to experiment with various changes without affecting the original project.

    In general, forks is used to change someone else's project (contribute code to an already open source project) or use someone else's project as an initial development point for your own ideas.

    Propose to change someone else's project

    A good example of using forks to propose a change is bug fixing. Instead of documenting a problem you find, you might as well:

      • Fork this warehouse
      • To repair
      • Submit a pull Requset to the owner of this project

    If the owner of the project agrees with your results, they may update your fix to the original warehouse!

    Use other people's projects as an initial development point for your own ideas

    The core of open source is shared code, and we can make better, more reliable software.

    In fact, when you create a warehouse on GitHub, you have the option to automatically include a license file that determines whether you want to share your project with others.

    Fork a warehouse is divided into two simple steps. We have created a warehouse for you to practice!

      1. On GitHub, locate the Octocat/spoon-knife warehouse.
      2. In the upper-right corner of the page, click the Fork button.

    That's it! Now you have to fork this original Octocat/spoon-knife warehouse.

     

    Sync your Fork Warehouse

    You may have already fork a project in order to commit changes to upstream or to the original repository. In this case, it's a good implementation to synchronize the upstream warehouse regularly to your fork. To do this, you need to use Git on the command line. You can use the Octocat/spoon-knife warehouse you just fork to practice setting up the upstream warehouse.

    First step: Install Git

    You should first install Git if you haven't. And don't forget to verify GitHub with Git.

    Step two: Create a local clone for your fork's warehouse

    Now that you have successfully fork the Spoon-knife warehouse, there is no file for this repository on your own computer. Let's clone your Fork's code to your local computer.

    1. On GitHub, locate the Spoon-knife warehouse where you fork.

    2. In the right sidebar of your fork's warehouse page, click the Copy icon to copy the URL of your fork.

    3. Open the Terminal command (for Apple system users) or command prompt line (for Windows and Linux users).

    4, enter git clone , and then paste the URL that you copied in step 2. It looks like this, using your GitHub username instead YOUR-USERNAME :

    clone https://github.com/YOUR-USERNAME/Spoon-Knife

    5. Press Enter and your local clone is created.

    $ git clonehttps://github.com/your-username/spoon-Knifecloning into  ' Spoon-knife ' ... remote: counting objects: 10, done. remote: compressing objects: Span class= "Hljs-number" >100% (8/8), Done. Remove: total 10 (Delta 1), reused Span class= "Hljs-number" >10 (Delta 1) unpacking objects: 100% (10/10) , done.                 

    Now you have the local clone code for your fork's Spoon-knife warehouse!

    Step three: Sync your fork's original Spoon-knife repository by configuring Git

    When you fork a project to make changes to this original repository, you can configure Git to change the original or upstream changes to your local.

    1, on GitHub, locate the Octocat/spoon-knife warehouse.

    2. In the right sidebar of this warehouse page, click the Copy icon to copy the URL of this repository.

    3. Open the Terminal command (for MAC users) or prompt the command line (Windows and Linux users).

    4. Change to the local directory where you created your fork in step 2 (Create a local).

      1. Go back to the root directory and enter only cd .
      2. Enter ls to list the files and folders for the current directory.
      3. Enter cd the directory name "into the directory you entered.
      4. Enter cd .. back to the previous directory.

    5, input git remove -v , press ENTER, you will see your fork is currently configured remote repository:

    $ git remote -vorigin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

    6. Enter git remote add upstream , then paste the URL you copied in step 2 and press ENTER. It looks as follows:

    $ git remote add upstream https://github.com/octocat/Spoon-Knife.git

    7. Verify the newly specified upstream warehouse in your fork and enter it again git remote -v . You will see the URL of your fork as the original address, and the original repository URL as upstream.

     $ git remote-vorigin https:/< Span class= "Hljs-regexp" >/github.com/your_username/YOUR _fork.git (Fetch) Origin https://github.com/your_username/your_fork.git (push) upstream  Https://github.com/original_owner/ original_repository.git (fetch) upstream https://github.com/original_owner/ORIGINAL_ Repository.git (push)             

    Now you can keep your fork in sync with upstream's warehouse and take advantage of a few Git commands. For more information, please refer to Syncing a fork.

    Retrieving other warehouses to Fork

    Each open warehouse can be fork, so you can search for items you are interested in and fork it!

    Explore GitHub is a big platform that allows you to find items of interest. Visit this page frequently to focus on the latest and coolest things.

    Follow a man

    A powerful feature of GitHub is the ability to see what other people are doing or related to.

    After you've followed someone on GitHub, you'll get a dynamic notification of their activity in your dashboard. You can click on the Follow button on their page.

    Watch a project

    In some cases, you may need to track the dynamics of a particular project in real time, which is similar to tracking a user, but only focuses on the events of that project. You can either send an email subscription to the project or configure the notification settings on the page. Compare typical notifications such as a comment on a patch or issue, or just a comment on a project.

    Our friend Octocat has a project called Hello World and we want to check it out.

    When you are on the project page, you will find a watch button at the top of the page and click on it.

    Congratulations, you have followed this Hello world project. If Octocat updates this item, you will be notified of changes in your control panel.

    GitHub for Windows installation

    1. Download the latest version of GitHub from Windows.github.com.

    2. When you open the software, you can choose to log in with your GitHub account or create a new account.

    3. On the left, you can see your GitHub account, and you can see the other (users) in your group. Click on a username and you will see which repositories are available and click Clone to clone the repository to your computer.

    4. Alternatively, you can click on the + add at the top to add a new local repository.

    You are ready to start programming and synchronize modifications with GitHub for Windows.

    Fork

    Cloning directly from GitHub to add libraries is also a good choice.

    1. You can use GitHub to browse related projects directly from your personal account or from the organization you belong to.

    2. You can also do one-click cloning directly on GitHub via the clone in Desktop button.

    Submit to Local

    You have updated the data locally and need to submit it to the local repository first:

    1. Click the name of the library you want to sync.

    2, you will see a form, listing your latest changes. Add a commit log (optionally add a description) and submit.

    Synchronizing remote Warehouses

    When there is a new local commit record, the In sync button is lit and the text becomes sync, just click the Sync button and sync to the remote repository on GitHub.

    GitHub for Mac Installation

    1. Download the latest version of GitHub from Mac.github.com.

    2. When you open the software, you can choose to log in with your GitHub account or create a new account.

    3. On the left, you can see your GitHub account, and you can see the other (users) in your group. Click on a username and you will see which repositories are available and click Clone to clone the repository to your computer.

    4. Alternatively, you can click on the + add at the top to add a new local repository.

    You're ready to start programming and sync changes with GitHub for MAC.

    Fork

    Cloning directly from GitHub to add libraries is also a good choice.

    1. You can use GitHub to browse related projects directly from your personal account or from the organization you belong to.

    2. You can also do one-click cloning directly on GitHub via the clone in Desktop button.

    Submit to Local

    You have updated the data locally and need to submit it to the local repository first:

    1. Click the name of the library you want to sync.

    2, you will see a form, listing your latest changes. Add a commit log (optionally add a description), then click Commit and Sync Master, commit the changes to the local repository, and synchronize to the remote repository at the same time.

    Synchronizing remote Warehouses

    When there is a new local commit record, the Sync button in the upper-right corner is lit and clicked to sync to the remote repository on GitHub.

GitHub User Manual-Basic article

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.