GitHub easy-to-use tutorials

Source: Internet
Author: User
Tags gpg git client

GitHub (https://github.com) is a git-based code hosting platform, where paid users can build private warehouses, and our general free users can only use public repositories, which means the code is open. Public repositories are sufficient for the average person, and we don't have much code to manage, O (∩_∩) o~. Here is a summary of some of my simple use, for beginners reference.

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 Msysgit

GitHub is a server, we need a git client to use git on our own computer, I choose Msysgit here, this just provides the core functionality of Git, and is based on the command line. If you want a graphical interface, just install Tortoisegit on msysgit basis.

After loading the msysgit right mouse will have some more options, in the local repository right-click Git Init here, will be more than a. git folder, which means that the local git 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

First, SSH key is created locally;

1 $ 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. In order to verify success, enter it under GIT bash:

1 $ 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.

The next thing we need to do is upload the local repository to GitHub, and then we'll have to set up username and email, because GitHub will record them each time it commits.

12 $ git config --global user.name "your name" $ git config --global user.email "[email protected]"

Go to the repository you want to upload, right-click Git Bash, add remote address:

1 $ 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

Next, add some files to the local repository, such as the Readme,

12 $ git add README $ git commit -m "first commit"

Upload to GitHub:

1 $ 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:

123 bin*.suoobj

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.

6.tag

We can create a tag to point to a key period of software development, such as the version number update can be built with a "v2.0", "v3.1" such as the label, so in the later review will be more convenient. Tag is very simple to use, the main operations are: view tag, create tag, verify tag and share tag.

6.1 View Tag

List all Tags:

1 git tag

The tags listed here are sorted alphabetically, and the creation time is fine. If you just want to see some tags, you can add a limit:

1 git tag -l v1.*

This will only list 1. Several versions.

6.2 Creating tags

Create a lightweight tag:

1 git tag v1.0

This creates a tag with no additional information, corresponding to the tag with the information:

1 git tag -a v1.0 -m‘first version‘

The back of-M is annotated, so it will be useful when you look at it later, this is the normal tag, and there is a signed tag:

1 git tag -s v1.0 -m‘first version‘

The premise is that you have GPG private key, you can change the above a to S on the line. In addition to adding tags to the current progress, we can add tags to the previous commit:

12345 #首先查看以前的commitgit log --oneline#假如有这样一个commit:8a5cbc2 updated readme#这样为他添加taggit tag -a v1.1 8a5cbc2
6.3 Delete Tag

Very simple, after knowing the tag name:

1 git tag -d v1.0
6.4 Verify Tag

If you have a GPG private key, you can verify the tag:

1 git tag -vv1.0
6.5 Share Tag

When we do git push, tag is not uploaded to the server, such as GitHub now, after the creation of the tag git push, on the GitHub page can not see the tag, in order to share these tags, you must:

GitHub easy-to-use tutorials (GO)

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.