A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
A simple introduction to GitHub's basic operations.
Home page: https://github.com/ first of all, it's natural to register an account on GitHub. Then start the text.Git Basic Introduction
Git is a distributed versioning system (distributed version control systems, referred to as Dvcs), the client will be the code warehouse full mirror to the local, and SVN and so on The centralized versioning system (centralized version control systems, referred to as CVCs) does not have a "central server" with a full repository on each client, so it does not require networking to work, improves security, It also supports powerful branch management.
There are only three states in git for any file: committed (committed), modified (modified), and staged (staged). committed identity The file has been securely stored in the local database, modified to indicate that a file has been modified, but has not yet been committed, and the staged representation puts the modified file on the list to be saved on the next commit. [ source ]
When Git manages a project, three working areas of the file flow:git's working directory , staging Area , and local repository . As shown in the following:
The basic git workflow is as follows: [ source ]
the following describes GitHub simple operation on the Web side:Creating a warehouse (Create a Repo)
1. Select "New repository" in the upper right corner of any page or "Create repositories" in GitHub bootcamp (training camp)
2, fill in the basic information warehouse:
RepositoryName: Warehouse names
Description (optional): Introduction to Warehouse Description
Public, private: Warehouse permissions (publicly shared, private, or designated collaborators)
Initialize This repository with a README: Initialize file readme.md
Gitignore: A repository type that does not need to be versioned, corresponding to the makefile. Gitignore
License: Certificate type, corresponding build file license
3. After creation as shown:
If Initialize this repository with a README is selected when it is created, a readme.md file is automatically generated if Add is selected . Gitignore , the. gitignore file is automatically generated and a license file is automatically generated if Add a license is selected;II Modification and submission (commit changes)
1, here take readme.md file as an example, click Open "readme.md" file in the
2. Select the edit icon in the upper right corner to edit
3, Add/Modify the text content, you can also preview in "Preview Changes"
Content that is modified or added is flagged in the preview
4. At the bottom of the page, fill in a brief submission or description of the modified/added content, then click "Commit Changes" to submit.
5. The location of the information provided in the submission of the modification information corresponds to the position of the warehouse directory browse as shown below:
Another: In the warehouse to add files, click on the right side of the warehouse "+" can be, the other operations are the same as above; note the suffix name in the file name.Three-copy warehouse (Fork a Repo)
Fork: Fork, in GitHub, a fork is equivalent to a copy of repository, of course, so you can in your own account in the warehouse in the experiment to modify the test, without affecting the original warehouse content.
into the warehouse where you want to fork (repository), for example Octocat/spoon-knife , and then click Fork in the upper-right corner to copy the warehouse to your account.
==>Quad Delete Warehouse (delete a Repo)
1. Enter the appropriate warehouse and select "Setting" in the toolbar on the right.
2. Then select Delete this repository
3, fill in the popup dialog box to delete the current warehouse name, confirm can
I generally do not like in the web-side editing operations or something, after all, maybe when you break the network or submit failed, and then painstakingly typesetting or editing the content on the fly, so I also focus on learning about the use of GitHub client, the following focus on the use of GitHub client.
The following describes the basic use of the Windows Client GitHub toolOne installation of GitHub for Windows (Windows 7 System)
1. Download github for Windows and install (this software installs and uninstalls a bit of egg ache, uninstall git shell will not be unloaded, but does not affect the use)
The two icons appearing on the desktop appear as shown, the UI Visual management tool on the left and the command Line management tool on the right;
2, connected to the GitHub account (can be connected via GitHub or git shell two ways to connect, too troublesome direct method one, the direct method of the pain of the egg two, the landlord obviously accounted for the second)
Then click "+" in the top left corner to see the items in your GitHub account
cmd corresponding window
Git Bash corresponding window
PowerShell corresponding window
And the final custom boot. Git Bash is the way to use it. (Lou Zhu, the difference between them why don't you say ah?) What difference do they have? Lou Zhu said, well the difference, Ah, who knows the difference? Please be self-reliant.)
Then set up git information, username and mailbox via the command line:
git config--global user.name "YOUR name" git config--global user.email "YOUR email ADDRESS"
The execution of these two lines of command corresponds to the Configure GIT setting in GitHub's "option";
Git is connected to GitHub via SSH, so you need to create a new SSH key from the command line:
Ssh-keygen-t rsa-c "YOUR EMAIL ADDRESS"
When the command is executed, the file save path is prompted by default in the. SSH folder under the System Users folder.
Here the default path, the direct carriage return, and then prompted to enter the password, you need to enter two times (you can also not enter the direct carriage two times);
It then generates information similar to the following
Execution here, you will be in the specified directory. SSH folder found two files generated, Id_rsa and id_rsa.pub
Next, you can copy the public key in the id_rsa.pub by text editing, or copy it by using the following command
Clip < ~/.ssh/id_rsa.pu
This public key is to be pasted into the SSH keys set by GitHub, as follows:
In the upper-right corner of any Web page on GitHub, click on the "Setting" icon, then select the "SSH Keys" tab in the "Personal Settings" column and click on "Add ssh key" in the top right corner.
Fill in a title as the logo, and then paste the previously copied public key into the text box below the key and click "Add Key".
Finally, you need to verify that the SSH key you added is successful, you can perform the following command verification, or open the GitHub client:
ssh-t [email protected]
If you see a warning message, similar to:
Leave him alone, yes. You can see a message similar to the following:
OK, here, the Git bash connection to GitHub is successful. Obviously, it's a bit of a git bash configuration process, or the first method is really simple, just try it out.Two-sync/clone warehouse to local (Sync/clone repository)
In the lower-right corner of each of your warehouse pages, there is an area as shown:
Click the icon to copy the repository's cloned address, and then execute the following code on the command line:
git clone https://github.com/your_username/your_repository_name.git
Note that the parameter after clone is the HTTPS clone URL that was previously copied on the Web page, and to paste in git bash, you need to do as shown:
Run the command to get the following prompt:
The Repository (repository) from the command line clone is stored in the corresponding user folder (C:\Users\ user name \) root directory.
Of course also can be through the GitHub client software faster clone repository, clone path it will prompt you to choose,
==> Click on the "Clone test" below ==>
If there are changes to the repository on the Web page that are not synced locally, you will be prompted at "sync" in the upper-right corner:
See clearly is down ↓ arrow OH
Click "Sync" to sync your edits locally:
If the files in the repository are modified locally and are not synchronized to the server, "uncommitted changes" appears on the "History", and the modified content is displayed on the right side of the expansion:
As with the web-side operation, this time you need to fill in the modified summary and description, and then submit (commit to Master), this time in the upper right corner of the "Sync" at the following:
This is the arrow that's up ↑ .
Click to sync to the server side!Three references
1, Liaoche's official website git tutorial
[GitHub] GitHub start tutorial
Start building with 50+ products and up to 12 months usage for Elastic Compute Service