在windows7下面装了个git
打开git bash
1、设置了下
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
2、生成了下公私钥
$ ssh-keygen -t rsa -C "youremail@example.com"
3、将id_rsa.pub的内容添加到github账户的SSH keys里面去
4、在网页中,在github上创建一个仓库demo,默认就好
5、本地创建一个文件夹demo
$ mkdir demo
5、本地文件夹demo下git初始化
$ git init
6、初始化一个文件demo.txt,并填入任意内容
7、添加demo.txt文件到本地仓库
$ git add demo.txt
$ git commit -m “demo.txt”
8、链接到远程仓库
git remote add origin git@github.com:yourname/demo.git
9、将本地仓库内容提交到远程仓库
$ git push -u origin master
以后提交时,不用加-u参数
容易产生的问题:
问题1、permission denied或者github does not provide shell access
In 'Git Bash':
Start the 'ssh-agent.exe' process
eval $(ssh-agent -s)
And install the SSH keys
ssh-add "C:\Users\MyName\.ssh\id_rsa"
问题2、error:src refspec master does not match any
原因: 本地版本库为空, 空目录不能提交 (只进行了init, 没有add和commit)