下载网址
https://git-for-windows.github.io/
开始安装
安装完毕,开始初始设置
#设置用户名
$ 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官网注册账号
本地创建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.com
The 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.com
The 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)? yes
Warning: 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.git
Cloning 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 0
Receiving objects: 100% (3/3), done.
Checking connectivity... done.
Administrator@YOUNG-PC MINGW64 ~/.ssh
$ cd Hello-Word/
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
$ ls
README.md
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
$ vi hello_word.php
$ cat hello_word.php
<?php
echo "Hello World"
?>
$ ls
hello_word.php README.md
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
#检查状态
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello_word.php
nothing added to commit but untracked files present (use "git add" to track)
提交
#这个命令加入了缓存区,但是还没真正提交
$ git add hello_word.php
warning: 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 young
warning: 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.php
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
#检查日志
$ git log
commit 3fff3cbb9151ec27b71e92cbd610f3356e023ba0
Author: Thinker young <x695@qq.com>
Date: Wed Mar 9 19:57:50 2016 +0800
Add hello world script by php. . _Thinker young
commit 183496d052ba08258495cb3bf62ac97252610e3b
Author: x695 <x695@qq.com>
Date: Wed Mar 9 19:35:23 2016 +0800
Initial commit
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
#推送的github上
$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to 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 corresponding
remote 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 -> master
Administrator@YOUNG-PC MINGW64 ~/.ssh/Hello-Word (master)
$