Initial experience and summary of Git/github

Source: Internet
Author: User
Tags git client hosting sites version control system

git, a magical and strange thing, incredibly until now to understand it, like a man said, now do not use git really embarrassed to say that they do it.

In short, this git is the most advanced distributed version control system, and he corresponds to the well-known SVN (a centralized version control system).

Centralized versioning system (centralized version control systems, referred to as CVCS), such as CVS, Subversion (SVN), and Perforce, all have a single, centrally managed server Save revisions of all files, and people who work together connect to the server through the client, take out the latest files, or submit updates. Over the years, this has become a standard practice for version control systems. This approach brings many benefits, especially compared to older local VCS. Now, everyone can see to some extent what other people in the project are doing. Administrators can easily control the permissions of each developer, and managing a CVCS is far easier than maintaining a local database on each client. There are two sides to things, good and bad. The most obvious disadvantage of this is the single point of failure of the central server. If you are down for an hour, no one can commit the update and work together within the hour. If the disk on which the central database is located is damaged and not properly backed up, there is no doubt that you will lose all of the data-including the entire change history of the project, leaving only individual snapshots that people hold on their respective machines. The local version control system also has a similar problem, as long as the entire project history is saved in a single location, there is a risk of losing all historical update records. In order to solve the problem of centralized version control system, the Distributed version control system (distributed, short DVCS) is available. In such systems, such as Git, Mercurial, Bazaar, and Darcs, the client does not just extract the latest version of the file snapshot, but instead completely mirrors the code repository. As a result, any server that works together fails and can be recovered using any of the mirrored local repositories afterwards. Because each cloning operation is actually a full backup of the code warehouse at one time. Similarly, referring to git, not to mention GitHub, feels like a lot of people think of them as something, but, in fact, GitHub is a git-based code hosting platform for hosting a variety of git libraries and providing a visual interface (https:// www.github.com), users can upload their own code to GitHub via a git client (Http://git-scm.com/download/win), and when they look at a git blog post, one person also mentioned other online hosting sites (HTTP/ Www.bitbucket.com, Http://www.git.oschina.net), the latter with respect to the other two advantages are: domestic, access faster,Supports both public and private projects. 
Specific Introduction

How to get Started:

1. Register your account

Our main purpose is to put our own project in a hosting platform, then for this platform requires a voucher, that is, the user name password, to github.com registration.

2. Installing the Client

GitHub is a server, we need a git client to use git on our own computer, I choose Msysgit (Http://git-scm.com/download/win), this just provides the core functionality of Git, and is based on the command line. If you want a graphical interface, just install Tortoisegit (https://code.google.com/p/tortoisegit/) on a msysgit basis.

3. Configure Git

Create a new project directory, right-click in the current directory, choose Git GUI here, create a file directory, at this time, the creation of a file directory will have a. git file, which means that the creation is complete;

Right-click Git Bash here, enter: $ ssh-keygen-t rsa-c "account name (email)", and then ask to confirm the path and enter the password, we use the default all the way to enter the line;

Right-click the Git GUI here and see a visual window, Help option, Show SSH key, copy the key value text inside;

Open github.com, login, select settings, select SSH key, add a new Key on the right, the content just copied, paste it here, the title casually, in order to let you distinguish between the other Key value represents what;

In order to verify success, right-click Git Bash here, enter: $ 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.

Open git Bash here and enter:

$ 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 here, 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 an Upload

Add a new file to your local repository, such as readme, right-click, Git Bash here, and enter:

$ git Add README

$ git commit-m "first commit"

$ 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. General questions:

The files in the warehouse may exist in these three states:

1)untracked files→ file is not tracked;
2)changes to be committed→ file has been staged, this is the next submission of content;
3) Changes bu not updated→ file was modified, but was not added to staging area. If the commit is not with the-a option, the file in this state will not be committed.

At the time of submission, untracked files often appear to be filenames are incorrect, this column is worth noting is case-sensitive, if the real file is a readme, then you write a readme will prompt the error.

The above content is basically from the big blogs, because this kind of article is now particularly many, so also do not want to go to repeat, because oneself is interested, learn to play, not commonly used, specially organize a copy, do memo.

Turn from:

Http://www.cnblogs.com/shuidao/p/3535299.html#!comments

https://wuyuans.com/2012/05/github-simple-tutorial/#toc-1

Initial experience and summary of Git/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.