"Go" git and GitHub for use under Ubuntu

Source: Internet
Author: User
Tags ssh access using git version control system

Original URL: http://www.cnblogs.com/cocowool/archive/2010/10/19/1855616.html

Recently started using Git to do some supplemental work on KOHANA3 's documentation, using Git and GitHub, from understanding to using, or a little distance, here are some of the ways to summarize.

1, the installation of Git

I use Ubuntu 10.04, which is not installed by default in Ubuntu, so you need to install Git in the system first.

sudo apt-get install Git-core

Once the installation is complete, enter git in the terminal to see the relevant commands. If you just need to use git to manage your local code, you can use it now. If you need to combine with a project on GitHub, there are other things to do.

2. GitHub Account Application

If you just need to copy the code of interest on GitHub to the local, make your own modifications, instead of sharing the publication, it doesn't matter if you don't apply for an account, just need git clone code locally. This article does not discuss this method, after all, using GitHub is for the purpose of open source.

First go to github.com to register an account, the specific registration process will not repeat.

3, create a local folder, and then do some initialization of global variables

git config--global user.name = "User name or User ID"

git config--global user.email = "Mailbox"

These two options are automatically added to your code during future use.

4. Create a public key for authentication

This is a more complex and confusing place for most people, because git accesses the repository through SSH, so you need to create a validation file locally.

Use command: ssh-keygen-c ' you email [email protected] '-t RSA

The corresponding key file is established under the user directory ~/.ssh/

You can use the ssh-v [email protected] command to test whether the link is unblocked

5. Upload Public key

Select Account Settings in the upper-right corner of the github.com interface and select SSH public Keys to select New Add.

Title can be arbitrarily named, the content of Key is copied from ~/.ssh/id_rsa.pub content, after completion, you can use ssh-v [email protected] to test. See the following information to indicate that the validation was successful.

Here, we can also use GitHub to manage our projects and participate in open source work, which is broadly divided into three ways.

Manage your own projects

This is a situation where you have some code locally and need to use GitHub to manage your own projects, and you can follow the steps below.

1, the establishment of warehouses

In the folder where you need to build the project, use git init to build the repository. When you are finished, you can see that there is one more. Git hidden directory in the file home.

2. Add Files

Use git Add. To make the initial file additions. Over here. Indicates that all the files under the folder are added, and we can also specify the file to be added.

3. Submit Documents

With git-m commit-m ' comment ' submission, you can submit the edited content.

You can see some of the status of the project through Git show.

This is the code that has been managed locally, but the local administration does not fully demonstrate the benefits of git.

Use GitHub to host your own projects

1. If you need to host your project on github.com, you first need to create a project. After selecting Create New Repository in Dashboard and filling in the relevant information, the project is created successfully.

2, after, there will be a reminder of how to upload, as already very detailed.

Fork someone else's project

As mentioned earlier, if just download the use of other people's code, through the Git clone can be, of course, the premise of cloning is that the project must be public, private projects are no way. If you need to participate, you can fork and then merge the way.

1, first need to go to their own interests in the project to fork,fork out a branch of their own. After fork, you can generally see an SSH access address. For example: [Email protected]:cocowool/userguide.git

2. Copy the Code

Use git clone [email protected]:cocowool/userguide.git userguide to copy your code to a local Userguide folder

3, make their own changes, the completion of the request for the original author merger

git pull person master

Here are some of the more useful commands:

# Create a repository git init# each time you modify it, you can save the changes to the stage (snapshot/index) git add <modified files># Modify a lot of files and use the following command to bulk store git Add. Commit the content in the snapshot/index to the repository using commit git commit-m "MSG" # can also be git add with git commit with a command to complete git commit-a-M "MSG" # The local git file with GitHub (remote) on the Sync git push# the github (remote) git file with local sync (i.e. update local repo) git pull# For example, the pull instruction actually contains the fetch (copy the changes back) and the merge (merge) operation to Git pulling git:// Github.com/tom/test.git # Another version control system branch function is also very interesting, if you modify the bug, but also add new features, you can fork out a branch: A special fix bug, a special to add new features, Wait until stable and then merge git branch Bug_fix # Build branch, named Bug_fixgit Checkout bug_fix # Switch to bug_fixgit checkout master #切换到主要的repogit Me Rge Bug_fix #把bug_fix这个branch和现在的branch合并 # If you have remote branch, want to view and Checkoutgit branch-r # view remote Branchgit checkout-b Bug_fi x_local bug_fix_remote #把本地端切换为远程的bug_fix_remote Branch and named Bug_fix_local # There are other tools that can view repo status git log # You can see the changes to Git diff #可以查看最近一次改变的內容 each commit, plus the parameters to see other changes and compare git show #可以看某次的变更 # If you want to know the status of the current working tree, you can enter GIT status

Resources:
1. Git and GitHub usage Guide in Windows environment
2. Using Git to manage source code
3, Git/github use of small notes
4. Using Git and GitHub to manage development

"Go" git and GitHub for use under Ubuntu

Related 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.