[Go] Upload project code to GitHub

Source: Internet
Author: User
Tags git client

1. Register your account and create a warehouse
The first step to using GitHub is, of course, registering a GitHub account. After that you can create a warehouse (free users can only build public warehouses), create a New Repository, fill in the name after create, there will be some warehouse configuration information, this is a simple git tutorial.


2. Installing the client Tortoisegit
GitHub is the server, to use Git on their own computer We also need a GIT client, I choose Tortoisegit here, he gives us a graphical interface operation. You need to install Git,http://msysgit.github.com/,tortoisegit first before installing:
http://code.google.com/p/tortoisegit/
After loading the right mouse will have a number of options, in the local repository right-click Git Init here, will be more than a. git folder, which means that local git was created successfully. Right-click Git bash to go to the GIT command line and configure SSH key to upload the local repository to GitHub.


3. Configure Git
(1) First create the SSH key locally;
$ ssh-keygen-t rsa-c "[email protected]"
The following [email protected] changed to your mailbox, then asked to confirm the path and enter the password, we use the default all the way to the line. Successful words will be generated under ~/. SSH folder, go in, open id_rsa.pub, copy the key inside. Go back to GitHub, go to account Settings, choose SSH keys,add ssh key,title on the left, and paste the Key.

(2) In order to verify success, enter it under GIT bash:
$ ssh-t [email protected]
If it is the first time will prompt whether continue, enter Yes will see: You ' ve successfully authenticated, but GitHub does not provide shell access. This means that you have successfully connected to GitHub.


(3) The next thing we need to do is to upload the local repository to GitHub, and we'll have to set up username and email before that, because GitHub will record them each time it commits.
$ git config--global user.name "your name"
$ git config--global user.name "your name" $ git config--global user.email "[email protected]"
(4) Go to the repository you want to upload, right-click Git Bash, add remote address:
$ git Remote add origin [email protected]: Yourname/yourrepo.git
The following yourname and Yourrepo indicate that you re-github user name and the newly created warehouse, added after the addition of the. git, open config, here will be a remote "origin" content, this is just added to the long-range address, You can also modify config directly to configure the remote address.

4. Submit, Upload
(1) Next add some files in the local warehouse, such as readme,
$ git Add README
$ git add readme$ git commit-m "First commit"
(2) Upload to GitHub:
$ GIT push origin master
The git push command pushes the local repository to the remote server.
The git pull command is the opposite.
After modifying the code, use GIT status to view the file differences, use git add to add files to commit, or use Git add-i to add files intelligently. After Git commit commits this modification, git push uploads to GitHub.

5.gitignore file
Gitignore as the name implies is to tell git to ignore the files, this is a very important and useful file. In general, we write the code after the compilation, debugging and other operations, which will produce a lot of intermediate files and executables, these are not code files, do not need git to manage. We see a lot of these files in git status, and if we add them with Git add-a, it's too cumbersome to add them manually. Then we need to gitignore. For example, General C # projects My. Gitignore is written like this:

Bin
. suo
Obj

Bin and obj are compiled directories, which are not source code, ignore; suo files are vs2010 configuration files, not required. This way you will only see the source code file when you are in Git status, and you can rest assured that Git is add-a.

[Go] Upload project code to GitHub

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.