Original: http://our2848884.blog.163.com/blog/static/146854834201152325233854/
Recently I feel the code on my computer is too messy, the East piece, the West piece ... Then decided to use the formal source control software to manage their own later writing code. Before the small project used to TortoiseSVN, feel good, but the speed is a bit slow, so decided to try something new--git. Discovering Git on the web is a fire, look at the text below and you'll know how much git is burning.
Git is a distributed version control system that was originally written by Linus Torvalds and used as the management of Linux kernel code. Since its launch, Git has also been a big success in other projects, especially in the Ruby community. Currently, many well-known projects, including Rubinius and Merb, use Git. Git can also be used by deployment tools such as Capistrano and Vlad the Deployer.
Most of the current version control requires a server side, commit when committed to the server side. Git is a distributed management tool, but it can also be managed in a centralized way. For example, Billy created a new project, and Tom thought the project was interesting, and he wanted to play, he could clone the whole repo (reoisitories) to the local, and he had a repo in his clone project. Tom is free to make various commits to the repo until he is satisfied. Tom could tell Billy what he had changed, and if Billy felt good, he could fetch it from Tom and merge it locally.
As mentioned earlier, as a distributed version control system, there is no concept of the main library in Git, and each copy of the library can be used independently, and any inconsistencies between the two libraries can be merged. That's why, with the GitHub site, GitHub is based on Ruby and is developed in multiple languages, and the Ruby project is also very active. In GitHub, everyone can have multiple repo, and these repo are tied to the user. The user can clone repo, fork repo, watch repo, or follow other user, just like a social networking site such as Twitter or Plurk.
However, if you use free github, all repo are public and have a 300M capacity limit. If you want to have private repo, you need to pay. GitHub also features a scrapbook that pastes code into it and freely develops various branch.
GitHub can host a variety of git libraries and provide a web interface, but unlike other services like SourceForge or Google Code, GitHub's unique selling point is the simplicity of branching from another project. Contributing code to a project is simple: first click on the "Fork" button of the project site, then check out the code and add the changes to the code base you just separated, and finally request a code merge from the project owner through the built-in pull request mechanism. GitHub has already been called the code player's Facebook.
Look at the above introduction, it feels good. So let's move on now.
1 Download and install related software
The main software involved here includes Msysgit and Tortoisegit.
Msysgit: Http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe
Tortoisegit: De.google.com/p/tortoisegit/downloads/list "href=" http://co%3Cwbr%3Ede.google.com/p/tortoisegit/ Downloads/list "rel=" nofollow ">http://code.google.com/p/tortoisegit/downloads/list (choose your favorite version to download)
You must first install Msysgit on your Windows PC before installing Tortoisegit. Because this program provides the Git core. And the installation sequence is: install Msysgit First, then install Tortoisegit. If you get it right, it doesn't matter, you can go to Tortoisegit's setup interface (Tortoisegit, Settings, General--msysgit, on the context menu), manually specify the Git core file Location (for example, C:\Program files\git\bin). Found no, when you enter the Setup interface, has been configured, have to say that the software is now very thoughtful.
2 Create your own account on the github.com
As I said earlier, GitHub is the programmer's Facebook, so we should have our own account. There are two types of accounts, free accounts and paid accounts. With free GitHub, all repo are public and have a 300M capacity limit, and if you wish to have private repo, you will be charged. In a free exchange of attitude, or to apply for a free account. This process is very easy, I will not say more.
After registering, GitHub offers a number of tutorials to help you quickly learn how to use GitHub. The address is as follows:
Set up git tutorial: http://help.github.com/win-set-up-git/
Create a repo tutorial: http://help.github.com/create-a-repo/
It is important to note that these tutorials use the Git bash provided by msysgit, and if you are very cold on the command line, then those tutorials are basically enough for you to refer to, no need to browse this article, or you can continue to appreciate the following.
3 Environment Configuration
In the attitude of learning, I follow the above tutorial walked a bit, found the problem:GitHub ssh:connect to host github.com Port
I am dull, did not solve the problem ... So back to the beginning, use Tortoisegit to manage your own GitHub project.
3.1 Configuring Msysgit in Tortoisegit
In the Start menu, find the settings of Tortoisegit, as shown in 1.
Figure 1 Location of settings in Tortoisegit
Since I am a 64-bit computer, I will show settings. Left-click to enter the Tortoisegit settings screen. As you can see clearly, the Msysgit has been configured well. If the location of the Git.exe is empty, please set it up manually.
Figure 2 Setup interface for Tortoisegit
3.2 Setting up a test project Hellogit
Create a new folder in the location where you want to place the project, name Hellogit, right-click the folder, and select "Git Create repository here ...", which is the local code base. The dialog box pops up and "OK" is selected. (PS: Do not respond to which check box) you will then be prompted to successfully create an empty code warehouse.
3.3 Adding files to Hellogit and updating items to the local repository
Create a new Readme file and fill in some information. Then mail click on the Readme and select "Git add ..." To add the Readme file to the local Hellogit project.
When you click OK, the following dialog box appears.
Click Commit to commit the update to the local repository.
Do not forget to fill in the "message" the completion of the submission of the task, easy to review the submission of information, the progress of the project has mastered. Click "OK" to continue.
3.4 Establish a communication between the remote repository and the Tortoisegit
The communication bridge mentioned here is the key used in the communication. Tortoisegit uses a key with an extension of PPK instead of the RSA key generated by Ssh-keygen. That is to say, using ssh-keygen-c "[email protected]"-t RSA generated key is not available in Tortoisegit. For GitHub-based development, the RSA key must be used, so the Tortoisegit Putty Key Generator tool is used to generate a PPK key that applies both to GitHub and to Tortoisegit.
Run the Puttygen program in the Tortoisegit Start menu, click the "Generate" button, move the mouse around the blank space until the progress bar is complete, will automatically give birth to a random key.
Login to GitHub website, click "Account Settings" in the upper right corner, select SSH public keys->add another public key, paste the key generated above, select "Add key". The public key is added complete. Then click "Save private Key" in the dialog above, save the private key locally, the file suffix is PPK.
Run the pageant program in the Tortoisegit Start menu, the program will automatically dock in the taskbar when it starts, the icon appears, double-click the icon, and the Key management list pops up. Click "Add Key" to select the PPK file you just saved so that the private key is added to the Key management list.
3.5 Updating items to the remote repository
This is our last step! But the premise is that we have to configure "Remote" in Tortoisegit. Right-click the Hellogit project, select Tortoisegit->settings, and the following dialog box appears.
The job we need to do is to configure the Git remote.
Remote is to give the project a name, we are hellogit;
The URL is the network address of the corresponding remote repository on GitHub. Do you have a serious look at the previous tutorial Ah, build a repo should be no problem. Add your own private key to the local Key management list, add your own public key to the corresponding project on GitHub, then we can continue, or we'll have to return to 3.4. When you enter your project on the website, you will see the following information:
As I've already said, I'm using SSH on my computer and can't connect to GitHub, so here's how I'm choosing http. [Email protected]:username/reponame.git is the URL we need.] (Ps:username and Reponame should be corresponding to your settings, in use you can not really use [email protected]:username/reponame.git, This is not even on the server)
The information we need to fill in the Putty is the path to the private key file we saved locally.
After filling out these three items, click "Add New" to display the remote information we added in the list on the left. Well, we can do one last job. Right-click on the Project Hellogit folder, select Tortoisegit->push, Pop-up dialog, select the remote information just added, click "OK", push successfully!
Well, it's getting late, good night, everybody! If you have any questions, please criticize me!