Git Tutorial (2) - How to Upload and Synchronize Your Own Git Project


This article is from http://blog.csdn.net/liuxian13183/  , and the reference must be indicated!


Git has been in contact and used for many years, and it is widely used in work. Its distributed storage makes everyone's computer a server. The strategy of making everyone's computer a server is very good; coupled with the use of Rsa encryption, the project can be managed by itself, and the public can submit Pr at will. Perfect, and finally merge branches by yourself, making Git the most popular version management tool in the computer world today.


Regarding the daily application of Git, some colleagues like to use GitFlow for interface management, but I prefer to use TorteriseGit and GitBash command line to operate. Simple, convenient and interesting are several keywords for bloggers to choose tools. Generally, it is used for company project management. In my spare time, I also like to make something myself and put it on Git, such as the test code snippets I often do. If I use Zip package to manage it, then how to synchronize the home and the company, and how to follow the code after leaving the company Synchronization of new companies, it is easy to think of GitHub, and Csdn and Code Cloud also have such functions, but Github has a long-standing reputation and is classic and convenient, so choose it.


Let me introduce the code snippets that I often do. There are a lot of them since my work, but they are mostly forgotten. They are mainly used to test certain ideas, such as algorithms, basic data types, multithreading, read and write streams, etc., and finally form the project ThinkingInJava , address: https://github.com/LiuzxGeek/ThinkingInJava


In fact, there is already an article before, but I feel that the introduction is relatively rough and not perfect. This time I will enrich the tutorial. Git tutorial and problem analysis


Upload first:

The first step, download the Git tool, whether GitFlow or TorteriseGit or GitBash, the blogger recommends the latter two together, because they choose them by themselves

The second step, right-click the project - select gitbash, configure the user name and mailbox, used to indicate identity when submitting, git config user.name/email "name/email"

The third step is to generate public and private keys, ssh-keygen -t rsa -C "as in your email". Put the public key in GitHub and own the private key for communication.

The fourth step, copy the public key content, put it in Github-the arrow on the right side of the avatar-select Settings-SSH and GPG keys-new SSH key-name and put it in

The fifth step, right-click on the project Git bash to execute git init (initialization), git add . (add all files to version management) and git commit -m "commit explanation"

Step 6. Under Github, new respsitory, create a new project named ThinkingInJava and save it

The seventh step, continue to enter git push --set-upstream [email protected]:LiuzxGeek/ThinkingInJava.git master on the command line


So far, the upload is successful! Then talk about synchronization

The first step, use puttygen.exe to generate the ppk file most needed for synchronization, select save public key and save private key (ppk file)

The second step, in the blank space, git clone, the file as shown below appears, select load putty key (you don't need to enter the user name and password in the future, just pull the code directly)



The third step, select, if you don't want to use the git command to keep typing, you can use it. Select the project, git Sync appears as shown below




Click Manage and fill in the following content




How to synchronize remote branches for Merge code.

1. Enter the project directory, right-click and select the merge option in TortoiseGit, the following interface appears


2. Click the "..." button, the following interface will appear


3. Right-click the project name of remotes and select fetch from "project name"

git fetch origin
git merge origin YOUR_BRANCH_NAME
git pull origin YOUR_BRANCH_NAME

至此,全部教程已经完毕,你可以流畅的上传、下载、同步代码了,如果有其他问题,欢迎评论!

对了,本教程同步可以用于多个账号同时上传,只需要公私钥和ppk命名不同即可,email和name作为私人项目,可改可不改。


问题1:TortoiseGit拉取代码,一直提示输入密码?

修改项目地址从“http”开头的,换到"git"开头的地址。


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325958983&siteId=291194637