###安装 查看是否安装,我的linux mint就自带的 首先,你可以试着输入git,看看系统有没有安装Git:
安装了
liuxiaoqiang@liuxiaoqiang ~/code $ git --version
git version 1.9.1
未安装
$ git
The program 'git' is currently not installed. You can install it by typing:
安装命令
sudo apt-get install git
###设置名字和邮箱
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
###创建仓库
找到你存放文件的目录,直接在当前目录下输入命令 如a/b/c.txt 就到a下面创建,这样子,直接把一个文件夹的内容就提交了
$ git init
Initialized empty Git repository in xxxxxxxx
在某某目录下建了一个空仓库
添加到仓库
$ git add readme.txt //上传文件
$ git add aa //上传文件夹
###提交到本地仓库
$ git commit -m "里面放你的提交说明"
$ git commit -m "wrote a readme file"
[master (root-commit) cb926e7] wrote a readme file
1 file changed, 2 insertions(+)
create mode 100644 readme.txt
###关联远程仓库,推送
要关联一个远程库,使用命令
$git remote add origin git@server-name:path/repo-name.git;
关联后,使用命令
$git push -u origin master第一次推送master分支的所有内容;
此后,每次本地提交后,只要有必要,就可以使用命令
$git push origin master推送最新修改;
###提示以下内容,输入yes
liuxiaoqiang@liuxiaoqiang ~/code $ git remote add orign git@github.com:qq450192529/comments.git
liuxiaoqiang@liuxiaoqiang ~/code $ git push -u orligin master
fatal: 'orligin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
liuxiaoqiang@liuxiaoqiang ~/code $ git push -u orign master
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
///秘钥问题暂未解决,待查找