Actions for GitHub Desktop on Windows

Source: Internet
Author: User
Tags git shell

1th. Upload the Open source code to GitHub

1.1 Git Windows Client

There are many Windows client software with git functionality, such as: Git for Windows (formerly Msysgit), Tortoisegit, GitHub Desktop (previous github for Windows) ...

The author's understanding of these clients:

1. Git for Windows

Git is native to Linux and needs to be ported to run on Windows. Git for Windows is one such porting project. Instead of just a program, it simulates a Linux environment on Windows.

The download URL for the git for Windows is https://git-for-windows.github.io/, the latest version is 2.10.2. It has two modes of operation: command line (Expert use), graphical interface (novice use). However, its graphical interface mode of operation is still relatively troublesome, so I did not choose it.

Git for Windows is an open source project, browse https://github.com/msysgit/msysgit to download the source code.

2, Tortoisegit

Tortoisegit is just a graphical interface program that internally calls git for Windows. Therefore, you need to install Git for Windows before using Tortoisegit.

Tortoisegit's biggest advantage is that it is the same as the TORTOISESVN operation, and users who are familiar with SVN can get started quickly.

3. GitHub Desktop

GitHub Desktop, like Tortoisegit, also calls git for Windows inside. But I think its operation is the simplest of the three software, after installation without configuration can be used, very suitable for beginners.

The download URL for GitHub desktop is: https://desktop.github.com/. The downloaded file GitHubSetup.exe is an online installer that may not be installed properly. To do this, you can download the offline installation package, which has a URL of http://pan.baidu.com/s/1Hkewm. Download Github_3_0_5_2.zip, unzip and run github.application can be installed.

Note: If the offline installer does not work, you will need to install the. NET Framework 4.5 first. You can run the online installer GitHubSetup.exe first to install the. NET Framework 4.5. Then run the offline Setup program.

1.2 Registering a GitHub account

To upload an open source code to github.com, you need to register an account on the site. Please visit the website https://github.com/and click the "Sign Up" button to register your account. The operation is relatively simple, will not repeat.

1.3 Login

Once you've installed GitHub desktop, you'll need to enter github.com's username and password the first time you run it, as shown in:

Figure 1.1

, after entering the user name and password, click the "Log In" button to complete the login.

1.4 Creating a local code warehouse

Click the button "+" in the upper left corner of the GitHub desktop screen to display the following screen:

Figure 1.2

Click the "Create" button, enter "Name" and "Local Path" and click the "Create Repository" button to complete the creation of the local code warehouse.

As shown, the essence of creating a local code warehouse is: 1) based on the settings, create a directory w:\ (YHF) \git\github\test;2) to generate two files in this directory. Gitattributes and. gitignore;3) execute git init in this directory command to generate a. Git directory (the directory is a hidden directory).

Figure 1.3

1.5 Creating a remote code warehouse

As shown in. In GitHub desktop, first select the local code warehouse test created in the previous section, and then click the Publish button in the upper-right corner.

Figure 1.4

Display the following interface

Figure 1.5

"Name" is the name of the remote code warehouse; "Description" is a description of the project. Clicking the Publish Test button completes the creation of the remote Code warehouse and passes the contents of the local code repository to the remote code repository.

This remote code warehouse is on github.com, as shown in:

Figure 1.6

1.6 Line Terminator

When you pass a file from the local code repository to a remote code repository, git is smart: it automatically replaces the line terminator of Windows \ r \ n (0DH, 0AH) with \ n. On this point, VC + +. NET means it doesn't matter, vc++6.0 is hurt (unable to parse. DSP and. dsw files). To prevent git from automatically changing the line terminator, you need to modify two files.

On Windows 7, modify the file C:\Users\Administrator\.gitconfig (Administrator is the user name when you log on to Windows). Add configuration Items Autocrlf and Safecrlf. As shown below:

Figure 1.7

Attention:

1, the file line terminator is \ n, that is, 0AH. So, I use UltraEdit to edit it, rather than the Windows system comes with Notepad;

2, Autocrlf and Safecrlf in front of the space is actually a tab (09H) character;

3. This file can only be modified once.

Modify the files in the local code repository. Gitattributes, you can use Notepad, as shown in:

Figure 1.8

, delete the auto in Text=auto and save it.

1.7 Commit changes to the local code repository

In the previous section, the files in the local code repository were modified. Gitattributes. This change should be submitted to the local code repository (in fact, to modify the local code repository files within the Git directory). Here's how:

As shown in. In GitHub desktop, first check the Code warehouse test and then go to "? Uncommitted Changes "page. After you enter the submission information, click the Commit to Master button.

Figure 1.9

The submission is complete when the prompt appears below the main GitHub desktop interface.

Figure 1.10

1.8 Synchronizing the Code warehouse

The previous section submitted the changes to the local code repository. This change can be submitted to the remote code warehouse through the synchronize operation.

Click the "Sync" button in the upper-right corner of the GitHub desktop screen, as shown in.

Figure 1.11

1.9 Adding files to the local code warehouse

Copy the code file into the folder where the local code repository is located, as shown in:

Figure 1.12

These files are then submitted to the remote Code warehouse as described in section 1.7, 1.8.

1.10 Deleting the Local code warehouse

Take the example of deleting the local code warehouse test for illustration. As shown, you can remove test from the GitHub desktop warehouse list by right-clicking the "Test" menu and clicking the "Remove" menu item.

Figure 1.13

The deletion above simply removes test from the GitHub Desktop Warehouse list, and the physical deletion of the local repository requires the removal of the folder W:\ (YHF) \git\github\test shown in Figure 1.3.

1.11 Adding a local code repository

The test was removed from the GitHub desktop warehouse list in the previous section, and the actual local repository was not deleted. At this point, you can increase the local warehouse. As shown in the following:

Figure 1.14

Once this is done, test will be added to the GitHub desktop warehouse list.

1.12 Delete Remote Code Warehouse

Browse the address of the remote code warehouse, such as: Https://github.com/hanford77/test, then go to the Settings page and click the "Delete this Repository" button.

2nd Chapter upload Open source code to Oschina

The remote code warehouse on the GITHUB desktop management github.com is easy to switch to, with other GIT servers, which can be manipulated differently. For example, GitHub Desktop cannot create a remote code repository on Oschina. This chapter will focus on how to upload open source code to Oschina.

2.1 Creating a Remote code warehouse

Login website Http://git.oschina.NET, create a project after registering your account, the page appears as follows:

Figure 2.1

Open Source License Selection Please refer to (from blog http://www.ruanyifeng.com/blog/2011/05/how_to_choose_free_software_licenses.html).

Figure 2.2

Click the Create button in Figure 2.1 to complete the project creation. As shown in the following:

Figure 2.3

Click SSH, and then click the Copy button at the right end to copy the project's URL ([email protected].net:hanford/test.git) to the Clipboard.

Note: You can also click HTTPS, and then copy the HTTPS URL for the project. The trouble with this URL is that when the local code warehouse synchronizes with the remote code warehouse, a user name and password are required.

2.2 SSH KEY

The previous section copied the SSH address of the project: [Email protected].net:hanford/test.git. Using SSH, this computer communicates with a remote PC with the same authentication (enter username and password), and SSH KEY is used to simplify authentication.

Before using SSH key, it needs to be created. Without using the git command line, GitHub Desktop has done all this for you. Enter C:\Users\Administrator\.ssh (Administrator is the user name when logging in to Windows) as shown in:

Figure 2.4

Github_rsa, Github_rsa.pub is the private key and public key required for GitHub desktop to communicate with github.com.

Id_rsa, Id_rsa.pub is the private key and public key required for GitHub desktop to communicate with other GIT servers.

Notepad opens id_rsa.pub Copy the public key, and then pastes the public key to the Oschina Web site as follows:

Figure 2.5

The 2nd item in the list is optional, and the 3rd is the public key. Click the OK button to complete the addition of a public key.

With the above configuration, GitHub desktop will use the private key and public key when communicating with the Oschina server, and no longer need to enter a username and password.

Note: github.com Why do I need to set up SSH KEY? Because GitHub desktop has done this work automatically. (So, GitHub desktop is really for beginners)

2.3 Cloning remote code warehouse to local

Click the "Github,inc" "Git Shell" menu item under the Windows Start menu, as follows:

Figure 2.6

The following command window is displayed

Figure 2.7

Enter the local Code warehouse directory (w:\ (YHF) \git\oschina), and then run the command

git clone [email protected]:hanford/test.git

Note: [Email protected]:hanford/test.git is the address of the project copied in Figure 2.3.]

After the command finishes, you can see the local code warehouse test under W:\ (YHF) \git\oschina. As shown in the following:

Figure 2.8

Use the 1.11 section method to add this local code repository to the GitHub desktop warehouse list. As shown in the following:

Figure 2.9

Note: The remote code warehouse for code warehouse test is not on github.com, so test is under other.

2.4 Other operations

For other operations, refer to section 1.6 (without modifying the file. Gitattributes), 1.7 knots, 1.8 knots, and 1.9 knots.

2.5 readme.md

When you create a remote code warehouse on Oschina, the file readme.md is created by default. It is a markup language file in the markdown format. is a description of the whole project.

For more information about the format of. md files, you need to note:

1, the line terminator is \ n (0AH);

2, the code is UTF-8, without BOM;

3, Github.com ignores line terminator.

Markdown the use of markup language, please check the relevant information on the Internet.

Actions for GitHub Desktop on Windows

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.