Getting started with Github

Source: Internet
Author: User
Tags git client sourcetree

Getting started with Github

Github Introduction
--------

When many people need to collaborate in our project, it is very convenient to have a public code document repository. Github.com is the most widely used service on the Internet. Although I am most familiar with SVN, I chose github to use better services.

The Help page on Github provides a guide for Bootcamp. In fact, Windows and Mac systems can be easily managed through clients provided by github, you only need to click Download Github for Mac/Windows to Download and install it. (Note: later it was found that the github client only supports the latest version of OSX. If it was earlier than 10.7, you can use other/more professional git clients, such as SourceTree)

However, the Linux system will be a little more troublesome, and we need to follow the instructions step by step. The steps for getting started with Github are as follows:

1. Set Up Git
2. Create a Repo
3. Fork A Repo
4. Be Social

The first step will show you how to set your name, account, and SSH key through the git command line. After generating the key, you need to upload it to your account settings, before you can perform other operations. The second step is how to create a repository, which usually contains the most basic README file, because the empty directory will not be uploaded to the repository. Step 3: If you want to change the branches of other repository, this applies when you do not have the permission to modify the repository, or do not want to mix your code with others' repository, you can use your own repository to modify your account, and use upstream to synchronize the original repository and repository code. Step 4 describes how to communicate with other users on github. There are other graphics clients in Linux, such as RabbitVCS, which can support both SVN, Git, and Mercurial, using the Toitoise series style in windows.

Note that in linux, if the private repository (private repository) of github is used, only the git clone command cannot be copied to the local host (or other clients ), use the following command line:

$ git clone git@github.com:username/projectname.git
After the previous steps, you can use git to store your code. Later, you also need to learn about the version control concept of Git, such as how to submit code, how to manage branches, and how to control versions. This should be combined with how to manage and submit code among team members.

 

Git concepts
-------

Github is a server that provides the Git code version management service. What are the benefits of using version control and code hosting?

  • We can browse our code and documentation (for example, arduino-exercises) anytime and anywhere through the github website ).
  • We can track all the changes submitted to the server (that is, if you do something bad, there will be records, such as the history of arduino-exercises)
  • We can back up existing work materials. If your hard disk is broken or your computer is lost, at least a backup is generated on the website.
  • We can make continuous changes to our work. Git allows you to create branches, save snapshots, merge and modify existing content, so that you can continuously improve your work without affecting the original version.

The following is a brief introduction to the file management process of Git:

1. Checkout. The first time we use fetch from the remote server and checkout HEAD to create a local working directory, we can add/delete/modify files in the working directory, then submit it to the local repository.
2. Add to Index. For the newly added file, we need to Add it to the Index so that the modification of the file will enter the Git tracking scope.
3. Commit. For files with indexes added, you only need to perform the "Submit to local repository" (Commit) operation when saving the changes. The changes to the file are available locally.
4. Push/Pull. Synchronize Local Repository and Remote Repository records. The verb used here is very vivid. Push is to Push the records of the Local warehouse to the server, and Pull is to Pull the records of the server to the local warehouse.

Git is a DVCS (Distributed Version Control System, Distributed Version Control System ), different from the traditional CVS/SVN version system, a central server must manage all version records. In fact, each repository can operate independently, which is called Distributed ). Git Repos can be either a server warehouse or a local file warehouse, which can exist in different folders or on others' computers, it can be fork/clone without limit to generate branches, and remember which branch their upstream (upstream) comes from. In this way, when warehouses with the same upstream have, you can use the shared version information to merge versions.

5. Merge (only when there is a conflict ). Sometimes, when we want to Push updates to the server, we find that someone else has updated the version on the server, that is, the Push records of others have not been downloaded to the local device, in this case, we need to first download others' changes to the local device to ensure that the changes are submitted based on the latest version before pushing the local records. If the modified part does not overlap with its own part, it should be able to automatically merge.

A simple merge method, such as Github Client, copies a copy of its version to another directory, and then Discard Local Changes (that is, cancel Local Changes, or Revert ), then update the Remote changes to the local device, and write your changes on the basis of the latest version.

Another method is to provide a more advanced way to handle conflicts in SourceTree, that is, you can directly modify the local file to the latest status, then Mark it as Resolved (right-click the file-> Resolve Conflicts-> Mark as Resolved). When you submit the file, you will think that this conflict has been committed by merged and can be committed successfully.

If you encounter problems during use, you can first view the Git client documentation. If necessary, I will explain how to perform tag/branch-related operations. This is an advanced step.

GitHub Tutorials:

Create a personal technical blog via GitHub

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

GitHub details: click here
GitHub: click here

This article permanently updates the link address:

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.