GitHub first experience - to save the project code to github repository

Because github deployment bottleneck, previously has been no good code management. Since the collapse computer once, after the disappearance of the code to understand the importance of sharpening wood workers are not wrong. 201803 github porter opened all the way. Records from the process 0-1: Handling the first small project how their semester at the beginning of practice to github repository.

Note: Content + combines several versions of their content, and strive to help the most comprehensive entry-white like me.

The following is a comprehensive ======= ========= 
First, create a github repository (warehouse), that is, you sign up for an account 
registered website  https://github.com/ 
Write pictures described here
click sign in-> Login 
click to sign up-> registration 
Write pictures described here

After filling out personal information to log into the main interface shown individual

Write pictures described here

Click New warehouse  (a warehouse corresponds to a project, can not appear to-many)

Write pictures described here

Write pictures described here

1.1 Creating a warehouse completed

Once created, you can see their warehouse address, so that my free remote repository is created. It also describes the common commands github repository. This directive will need to install git client locally.

Second, install Git client 
official Download: http://git-scm.com/download/  download the corresponding version of the system according to your own 
choice to install components by default be just fine.

1) Icon Component (Addition icons): Select whether to create Quick Launch bar icon, or whether to create a desktop shortcut;

2) desktop browser (Windows Explorer integration): browse the source code of the method, separate context browse using only bash or just use Git GUI tools; advanced contextual navigation methods using git-cheetah plugin plug;

3)关联配置文件(Associate .git*) : 是否关联git配置文件, 该配置文件主要显示文本编辑器的样式;

4)关联shell脚本文件(Associate .sh) : 是否关联Bash命令行执行的脚本文件;

5)使用TrueType编码 : 在命令行中是否使用TruthType编码, 该编码是微软和苹果公司制定的通用编码;

Write pictures described here

设置环境变量 : 选择使用什么样的命令行工具, 一般情况下我们默认使用Git Bash即可, 默认选择;

1)Git自带 : 使用Git自带的Git Bash命令行工具;

2)系统自带CMD : 使用Windows系统的命令行工具;

3) 二者都有 : 上面二者同时配置, 但是注意, 这样会将windows中的find.exe 和 sort.exe工具覆盖, 如果不懂这些尽量不要选择;

Write pictures described here

选择换行格式 ,依然是默认就好。

1)检查出windows格式转换为unix格式 : 将windows格式的换行转为unix格式的换行在进行提交;

2)检查出原来格式转为unix格式 : 不管什么格式的, 一律转为unix格式的换行在进行提交;

3)不进行格式转换 : 不进行转换, 检查出什么, 就提交什么;

Write pictures described here

选择终端模拟器,依然默认就好

1)使用MinTTY,就是在Windows开了一个简单模拟Linux命令环境的窗口Git Bash

2)使用windows的系统的命令行程序cmd.exe

Write pictures described here

选择默认就好,不用文件系统缓存

Write pictures described here

2.1安装成功完成。

三、绑定用户 
打开git-bash.exe,在桌面快捷方式/开始菜单/安装目录中 
或者右击点击Git Bash Here进入界面

Write pictures described here

因为Git是分布式版本控制系统,所以需要填写用户名和邮箱作为一个标识,用户和邮箱为你github注册的账号和邮箱

Write pictures described here

ps : git config –global 参数,有了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然你也可以对某个仓库指定的不同的用户名和邮箱。

四、为Github账户设置SSH key

众所周知ssh key是加密传输。

加密传输的算法有好多,git使用rsa,rsa要解决的一个核心问题是,如何使用一对特定的数字,使其中一个数字可以用来加密,而另外一个数字可以用来解密。这两个数字就是你在使用git和github的时候所遇到的public key也就是公钥以及private key私钥。

其中,公钥就是那个用来加密的数字,这也就是为什么你在本机生成了公钥之后,要上传到github的原因。从github发回来的,用那公钥加密过的数据,可以用你本地的私钥来还原。

如果你的key丢失了,不管是公钥还是私钥,丢失一个都不能用了,解决方法也很简单,重新再生成一次,然后在github.com里再设置一次就行

4.1 生成ssh key

首先检查是否已生成密钥 cd ~/.ssh,ls如果有3个文件,则密钥已经生成,id_rsa.pub就是公钥

Write pictures described here

如果没有生成,那么通过$ ssh-keygen -t rsa -C “自己的邮箱地址”来生成。

1)是路径确认,直接按回车存默认路径即可

2)直接回车键,这里我们不使用密码进行登录, 用密码太麻烦;

3)直接回车键

Write pictures described here

生成成功后,去对应目录用记事本打开id_rsa.pub,得到ssh key公钥

Write pictures described here

4.2 为github账号配置ssh key

切换到github,展开个人头像的小三角,点击settings 
然后打开SSH and GPG keys菜单, 点击Add SSH key新增密钥,填上标题,跟仓库保持一致吧,好区分。 

接着将id_rsa.pub文件中key粘贴到此,最后Add key生成密钥吧。

(pub文件是office可由office下的publisher打开,如果没有安装的话,可以选择浏览,利用word或者记事本打开)

Write pictures described here

So, github account SSH keys configured.

V. upload local project to github

Github method for uploading the project, there are two ways: one by https, one kind through ssh.

Described method is https

Find the code you want to upload a folder (such as Text). Right-click the Test folder root, click the "Git Bash Here", open the git command line.

According to the document prompts on the new github repository, submit items:

1. From the command line, enter "git init", added the Test folder git management;

2. Enter "git add." (Do not leak. ""), The entire contents of the folder Test Add to git.

3. Enter "git commit -m" first commit "" ( "" information submitted "git commit -m")

4. Enter "git the Add Remote Origin  https://github.com/xxx/Test.git" (gi t  Remote Origin the Add your own https address), connect your guthub warehouse.

5. Enter "git push -u origin master", upload the project to Github. Github here will be asked to enter the account password, you can enter as required.

Submit the project is successful, as shown:





Published 10 original articles · won praise 2 · Views 1799

Guess you like

Origin blog.csdn.net/weixin_41814051/article/details/79583128