Git初次入门

来源:互联网 发布:淘宝盗图原图制作软件 编辑:程序博客网 时间:2024/04/29 04:25

下载网址

https://git-for-windows.github.io/

开始安装

git安装1

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

安装完毕,开始初始设置

#设置用户名$ git config --global user.name "Thinker young"Administrator@YOUNG-PC MINGW64 ~#设置密码$ git config --global user.email "x695@qq.com"Administrator@YOUNG-PC MINGW64 ~$ git config --global color.ui auto

去githug官网注册账号

https://github.com/

本地创建ssh-key

$ ssh-keygen -t rsa -C "x695@qq.com"Generating public/private rsa key pair.Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):Created directory '/c/Users/Administrator/.ssh'.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.The key fingerprint is:SHA256:CkuSFGV984+wxdln9xbCOgA2gfpq3xOaSixxqnyz924 x695@qq.comThe key's randomart image is:+---[RSA 2048]----+|  ..o....        ||   o ..+o        ||  . . ..o+ o.    || . o    ..= .oo..|| .o.+   S+.o.o..o||  =o + o. .o.   o|| o oo + .   .  . ||o o= +.E         ||..oo*.++.        |+----[SHA256]-----+

官网添加此时的公钥

这里写图片描述

这里写图片描述

这里写图片描述

添加完成后,本地测试

Administrator@YOUNG-PC MINGW64 ~/.ssh$ ssh -T git@github.comThe authenticity of host 'github.com (192.30.252.128)' can't be established.RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.Hi x695! You've successfully authenticated, but GitHub does not provide shell access.

建立一个仓库

这里写图片描述

连接仓库

这里写图片描述

Administrator@YOUNG-PC MINGW64 ~/.ssh$ git clone git@github.com:x695/Hello-Word.gitCloning into 'Hello-Word'...Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.remote: Counting objects: 3, done.remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0Receiving objects: 100% (3/3), done.Checking connectivity... done.Administrator@YOUNG-PC MINGW64 ~/.ssh$ cd Hello-Word/Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)$ lsREADME.mdAdministrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)$ vi hello_word.php$ cat hello_word.php<?phpecho "Hello World"?>$ lshello_word.php  README.mdAdministrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)#检查状态$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.Untracked files:  (use "git add <file>..." to include in what will be committed)        hello_word.phpnothing added to commit but untracked files present (use "git add" to track)

提交

#这个命令加入了缓存区,但是还没真正提交$ git add hello_word.phpwarning: LF will be replaced by CRLF in hello_word.php.The file will have its original line endings in your working directory.#真正提交$ git commit -m "Add hello world script by php. _Thinker young"[master 3fff3cb] Add hello world script by php. . _Thinker youngwarning: LF will be replaced by CRLF in hello_word.php.The file will have its original line endings in your working directory. 1 file changed, 3 insertions(+) create mode 100644 hello_word.phpAdministrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)#检查日志$ git logcommit 3fff3cbb9151ec27b71e92cbd610f3356e023ba0Author: Thinker young <x695@qq.com>Date:   Wed Mar 9 19:57:50 2016 +0800    Add hello world script by php. . _Thinker youngcommit 183496d052ba08258495cb3bf62ac97252610e3bAuthor: x695 <x695@qq.com>Date:   Wed Mar 9 19:35:23 2016 +0800    Initial commitAdministrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)#推送的github上$ git pushwarning: push.default is unset; its implicit value has changed inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the traditional behavior, use:  git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:  git config --global push.default simpleWhen push.default is set to 'matching', git will push local branchesto the remote branches that already exist with the same name.Since Git 2.0, Git defaults to the more conservative 'simple'behavior, which only pushes the current branch to the correspondingremote branch that 'git pull' uses to update the current branch.See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' if you sometimes use older versions of Git)Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.Counting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 332 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To git@github.com:x695/Hello-Word.git   183496d..3fff3cb  master -> masterAdministrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)$

github查看

这里写图片描述

0 0
原创粉丝点击