一、使用git在本地创建一个项目的过程
$ makdir ~/hello-world //创建一个项目hello-world
$ cd ~/hello-world //打开这个项目
$ git init //初始化
$ touch README
$ git add README //更新README文件
$ git commit -m 'first commit' //提交更新,并注释信息“first commit”
$ git remote add origin git@github.com:defnngj/hello-world.git //连接远程github项目
$ git push -u origin master //将本地项目更新到github项目上去
如果输入$ git remote add origin git@github.com:gemlee(github帐号名)/gitdemo(项目名).git
提示出错信息:fatal: remote origin already exists.
解决办法如下:
1、先输入$ git remote rm origin
2、再输入$ git remote add origin git@github.com:djqiang/gitdemo.git 就不会报错了!
二、 git的初始化
正常安装后打开git bash开始配置
输入用户信息配置
git config --global user.name "姚欣炜"
git config --global user.email "535198569@qq.com"
ssh-keygen -t rsa -C "yaoxw@ucweb.com"
一路回车,在用户主目录下生成 .ssh,然后将文件夹里的id_rsa.pub内容在github上配置即可。
如果在bash输入ls中文显示乱码,可打开git安装目录的Git\etc\git-completion.bash
加入alias ls='ls --show-control-chars --color=auto'