Uploading projects to GitHub using Git

Source: Internet
Author: User
Tags git client using git version control system

From: http://www.cnblogs.com/specter45/p/github.html

GitHub is a git-based implementation of code hosting. Git is the best version control system available today, and is much more popular than SVN.

GitHub is free to use and fast and stable. Even for a paid account, the cost of not exceeding 10 US knives per month is also very cheap.

With GitHub, you can archive projects, share conversations with others, and let other developers help you with this project. The advantage is that he supports multiple people to complete a project, so you can talk on the same page.

Create your own projects and backup, the code does not need to be saved locally or on the server, GitHub is doing very well.

There are also many benefits to learning about Git. He is seen as a pre-maintenance process, you can recover as you need, submit problems, or you need to recover any form of code, can avoid a lot of trouble. One of the best features of git is the ability to track errors, which makes using GitHub easier. Bugs can be made public, and you can submit errors via GitHub comments.

On the GitHub page, you can start directly without having to set up a host or DNS.

For me, I can edit the same set of code in the company and the home, with a U disk or a network disk is very troublesome to say

Theory says too much easy to forget, to practice it.

Outline:

First, create a GitHub repository (warehouse)

Second, install the Git client

Third, set up SSH key for GitHub account

Iv. uploading local projects to GitHub

First, create a GitHub repository (warehouse)

1-1 Logging in to GitHub

GitHub official website: https://github.com, if no account, hurriedly register a.

Click Sign in to enter the login screen, enter your account number and password to login to GitHub.

1-2 Creating a Repository (warehouse)

Why call Repository (warehouse)? I was beginning to wonder, wouldn't it be easier to call the codebase a little more straightforward? But carefully pondering, the warehouse is generally put food, it is the code as a full belly of things, more love, instantly feel this cold cold code filled with chakra.

Pull away, see how to create a warehouse, you can see the Repository tab after logging in

If not in this page also does not matter, click on the top right corner of the picture next to the small triangle, expand can see your profile, click Enter can also see repository

Switch to the Repository tab and you can see the new button that is very visible. Don't hesitate to click on it and start creating your own granary.

The following is the creation of warehouse information, only the name is required, and now I created a warehouse called: Beautifulday

Once created, you can see your warehouse address, so my remote free warehouse is created. It also describes the common instructions for the GitHub warehouse. This command requires a local git client to be installed.

Git init//Turn this directory into a repository that git can manage

git add readme.md//file added to warehouse

git Add. Not only can be with a single file, but also with wildcards, you can follow the directory. At a point, all the untraceable files in the current directory are all Add.

Git commit-m "First commit"//Submit file to Warehouse

git remote add origin [email protected]:wangjiax9/practice.git//Associated repository

Git push-u origin master//pushes all the contents of the local library to the remote library

Second, install the Git client

Git is currently the world's most advanced distributed version control system, five basic differences between Git and SVN. It has the following characteristics:

Distributed: Git version control system is a distributed system, is used to save the project source code history State of command-line tools;

Save point: Git can keep track of the files in the source code, and can get the whole project amount status at a certain point in time; Can be in the save point of multiple submissions of the source code merge, you can also fall back to a savepoint;

git offline operation: git can be offline for code submission, so it is called a full distributed processing, git all the operations do not need to be online; This means that git is much faster than tools like SVN, because tools like SVN need to be online to operate, and if the network environment is bad, the commit code becomes very slow;

Git-based snapshot: Old version control tools like SVN save the commit point to a patch file, and Git commit is to point the commit point to the project snapshot at the time of submission, which contains some metadata (author, date, GPG, etc.);

git branching and merging: The branching model is the most significant feature of Git, because it changes the developer model, and SVN and other version control tools put each branch in a different directory, and git can switch between different branches in the same directory;

Branch immediacy: Creating and switching branches is done almost simultaneously, the user can upload a subset of branches, another branch can be hidden locally, without having to upload all the branches to GitHub;

Branching flexibility: Users can create merge delete branches at any time, multi-people realize different functions, can create multiple branches for development, then branch merge, this way makes development fast, simple and secure.

2-1 Download git client

Official: http://git-scm.com/download/download the corresponding version according to your own system, didn't think it knew I was Windows ^_^

2-2 Installing the Client

Download good after we start to install it, welcome interface, next.

Choose the installation path, do not choose the path with Chinese, and sometimes cause unnecessary misunderstanding.

Select the installation component and press the default to do so.

1) Icon Component (addition icons): Choose whether to create a Quick Launch bar icon or whether to create a desktop shortcut;

2) Desktop Browsing (Windows Explorer integration): The way to browse the source code, separate context browsing using only bash or git GUI tools only; Advanced contextual browsing methods using the Git-cheetah plugin plugin;

3) association configuration file (Associate. git*): Whether to associate a git configuration file that mainly displays the style of the text editor;

4) Associated shell script file (Associate. sh): Whether to associate a script file executed by the bash command line;

5) Use TrueType encoding: whether to use Truthtype encoding at the command line, which is a generic encoding developed by Microsoft and Apple;

Set the directory name of the shortcut in the Start menu, the default is OK, the next step

Set environment variables: choose what command-line tool to use, in general we use GIT bash by default, the default choice;

1) git comes with: git bash command-line tool that comes with git;

2) system comes with cmd: command-line tool using Windows system;

3) Both have: The above two are configured at the same time, but note that this will be in Windows Find.exe and Sort.exe tools to cover, if not understand these try not to choose;

Choose the line-wrapping format, which is still the default.

1) Check out the conversion of Windows format to UNIX format: the line wrapping in Windows format to UNIX format is being submitted;

2) Check out the original format to UNIX format: No matter what format, all into the UNIX format of the line to commit;

3) do not format conversion: Do not convert, check out what, just submit what;

Select terminal Emulator, still the default is good

1) using Mintty, Windows opens a simple simulation Linux command environment for Windows git Bash

2) command-line procedures for Windows-cmd.exe systems

Select default is good, do not use file system cache

Installation ...

Git finally installs successfully.

2-3 Binding Users

Open Git-bash.exe, in Desktop shortcuts/Start menu/installation directory

Because Git is a distributed version control system, you need to fill in the username and mailbox as an identity, user and mailbox for your GitHub registered account and email

The ps:git config–global parameter, with this parameter, indicates that all git repositories on your machine will use this configuration, and of course you can specify a different user name and mailbox for a warehouse.

Third, set up SSH key for GitHub account

SSH key is known to be encrypted transmission.

There are many algorithms for encrypting the transmission, and one of the core problems that Git uses rsa,rsa is how to use a pair of specific numbers so that one of the numbers can be used for encryption, and the other can be used to decrypt the data. These two numbers are the public key that you encounter when you use Git and GitHub, and the private key.

Where the public key is the number that is used for encryption, which is why you upload it to GitHub after you have generated the public key in this machine. From GitHub, the data encrypted with that public key can be restored with your local private key.

If your key is lost, whether it is a public key or a private key, the missing one is useless, the workaround is simple, regenerate again, and then set it again in github.com.

3-1 Generate SSH Key

First check whether the key CD ~/.ssh,ls has been generated, if there are 3 files, the key has been generated, id_rsa.pub is the public key

If it is not generated, it is generated by $ ssh-keygen-t rsa-c "[email protected]".

1) is the path confirmation, directly press ENTER to save the default path

2) Direct Enter, here we do not use the password to log in, with the password too troublesome;

3) Direct Enter

After the build succeeds, go to the corresponding directory to open id_rsa.pub with Notepad and get SSH key public key

3-2 configuring SSH key for GitHub account

Switch to GitHub, expand the small triangle of your avatar, and click Settings

Then open the SSH keys menu, click Add SSH key Add key, fill in the title, with the warehouse to be consistent, good distinction.

Then paste the key in the Id_rsa.pub file to this, and then add key to generate the key.

So, the SSH keys configuration for the GitHub account is complete.

Iv. uploading local projects to GitHub

4-1 Creating a local project

I created a few empty folders and a file and a project configuration file, a lot of front-end projects like this architecture, I also follow the trend ha.

4-2 Creating a local warehouse

Let's review the instructions for creating a new warehouse:

Git init//Turn this directory into a repository that git can manage

git add readme.md//file added to warehouse

git Add. Not only can be with a single file, but also with wildcards, you can follow the directory. At a point, all the untraceable files in the current directory are all Add.

Git commit-m "First commit"//Submit file to Warehouse

git remote add origin [email protected]:wangjiax9/practice.git//Associated repository

Git push-u origin master//pushes all the contents of the local library to the remote library

First, go to the Beautifulday project directory, remember to create the warehouse after the success of the page, instructions are in it.

Then execute the instructions: Git init

After the initialization is successful you will find a hidden folder in the project. Git

This directory is git used to track the management of the repository, do not manually modify the directory inside the file, or change the mess, the Git repository to destroy.

Next, add all the files to the warehouse

Execute command: Git Add.

The file is then submitted to the warehouse, and the comment is submitted in double quotation marks.

Execute command: Git commit-m "Submit file"

So the local warehouse is set up.

4-3 Associated GitHub repositories

Copy warehouse address to GitHub Beautifulday Warehouse

Then execute the command: Git remote add origin [email protected]:wangjiax9/beautifulday.git

4-4 uploading Local Code

Execution instructions: Git push-u origin Master

1) Tap one: Yes, then enter

Here, the local code has been pushed to the GitHub repository and we are now going to the GITHUBT warehouse to see.

Hey! Strange, where's my catalogue? The hole suddenly came out is not very impressive

Note: Git cannot manage empty folders, there must be files in the folder to add

Okay, let's try it, I've created a test1.html file in examples.

Execute instruction Add FILE--Submit file--Push file

git Add.

Git commit-m "Submit test1.html"

Git push-u Origin Master

Then refresh a github and you'll see that the examples folder comes out.

Open the examples folder, test1.html is also inside.

Summarize:

Now it's time to comb through the basics of GitHub with a blog that's impressive and should not be fragmented. If you want to know more about git operations and knowledge, it's recommended to take a look at Mushe's git tutorial, which is very detailed.

Wish everyone Monkey monkey beauty, earn monkeys more monkeys, the mood monkey good monkey, Luck monkey shun monkey, sleep monkey fragrant monkey fragrant, love monkey sweet Monkey sweet, in short, all monkey honey Monkey honey!

Recommended Reading and reference:

Mushe's git tutorial

Five basic differences between Git and SVN

Git client diagram details how to install the Configure GitHub Walkthrough

Uploading projects to GitHub using Git

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.