git 添加到环境变量
github 新增仓库的后的提示…or create a new repository on the command line
echo "# top" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/liangkeno/top.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/liangkeno/top.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
1,找到安装git的安装目录,C:\Program Files (x86)\Git\bin,win7在计算机属性中添加路径
2,使用命令行添加,set PATH=%PATH%;C:\Program Files (x86)\Git\bin
git 简明教程:http://rogerdudler.github.io/git-guide/index.zh.html
安装git的记录
1,配置git的全局参数,包括用户名,邮箱地址,生产SSH公密钥
1--,命令行设置用户名,邮箱
git config --global user.name "username"
git config --global user.email "username@email.com"
2,push.default参数主要是设置在执行push命令是的策略,主要的选项有以下几个:
[*]nothing : Do not push anything
[*]matching : Push all matching branches (default)
[*]tracking : Push the current branch to whatever it is tracking
[*]current : Push the current branch
这里我们手动设置成默认值:
git config --global push.default matching
3,生成SSH key,在开始菜单中找到git bash并运行
$ssh-keygen -t rsa -C "username@email.com"
此时会提示你输入存储key的文件名(我输入github),并提示你输入密码与确认密码(我这里选择不输入),接着会生成连个文件名一个是公钥与私钥文件并存储在C:\Users\***文件夹下:github,github.pub
https://images2015.cnblogs.com/blog/469083/201607/469083-20160722150728435-1965640645.jpg
config文件,防止链接出现错误,代码如下:
1 Host github.com
2 User git
3 Hostname ssh.github.com
4 PreferredAuthentications publickey
5>
6 Port 443
4,绑定本机git与github
1--,打开github.pub公钥文件,拷贝里面公钥文本
2--,登陆官网https://github.com/,创建账号,进入设置,在SSH and GPG keys设置公钥,
5,打开git bash,输入ssh git@github.com测试是否连接上github
显示如下信息即已经连接成功
$ ssh git@github.com
PTY allocation request failed on channel 0
Hi ****! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
5,到此,既可以使用本机上的git连接github上的repository了
使用git Bash 添加文件从本地到github仓库
1,第一次更新到仓库
1--,初始化本地仓库,
git init
2--,更新到版本库
$ git add * //错误提示
warning: LF will be replaced by CRLF in package.json.
The file will have its original line endings in your working directory.
解决方法:
$ git config --global core.autocrlf false
//更新所有文件
$ git add .
//更某个文件
$ git add 文件名
//更某个目录
$ git add 目录名/
此时只是把文件放置缓存区
3--,添加注释
$ git commit -m "相关说明"
4--,关联到远程仓库
$ git remote add origin git@github.com:yourname/yourgit.git
5--,推送到远程仓库
$ git push -u origin master
2,再次更新到仓库,使用 add>>commit>>push origin master 即可
git add .
error: filename too long
git config --global core.longpaths true
3,把远程更新到本地仓库
下载远程到本地 :git fetch origin master
合并远程到本地:git merge origin/master
页:
[1]