利用github做版本控制。
1.git安装:
(1)安装git
sudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-daemon-run git-el git-arch
(2)检查SSH
ssh -T git@github.com
若看到提示:
Warning: Permanently added ‘github.com,204.232.175.90’ (RSA) to the list of known hosts.
Permission denied (publickey).
说明可以链接
(3)安装SSH keys
检查是否已有ssh keys
cd ~/.ssh
ls
发现没有id_rsa和id_rsa.pub这两个文件,如果有的话,需要备份之后移除
执行下面命令
ssh-keygen -t rsa -C "你自己的github对应的邮箱地址"
将刚刚创建的ssh keys添加到github中
利用gedit查看id_rsa.pub的内容,复制到 Settings -> SSH Keys -> Add SSH Key中,注意没有换行和空格。
再次输入
ssh -T git@github.com
看是否添加成功
2.使用github:
(1)配置github
利用自己的用户名和email配置git
git config --global user.name "你的github用户名"
git config --global user.email 你的github邮箱地址
设置成功后,输入
ssh -T git@github.com
可以查看有没有成功
(2)在github上新建仓库,是自己工程的名字
(3)本地新建工程,和github上仓库的名字一样
(4)本地仓库初始化
cd 本地文件所在路径
git init
添加全部文件
git add ./
添加项目说明
git commit -m 'my first version‘
上传该项目
git remote add origin git@github.com:你的github用户名/你的github项目名.git
git push origin master
这个时候就已经把本地项目备份到github上
(5)仅添加单个文件
touch Readme
git add Readme
git commit -m 'add readme file'
git remote add origin https://github.com/你的github用户名/你的github仓库.git
git push origin master
(6)从github上clone下来
git clone https://github.com/你的github用户名/github仓库名.git
1.克隆github上已有的仓库
git clone https://github.com/你的github用户名/github仓库名.git
2.或者是在github上新建仓库并且在本地新建同名的仓库
cd ~/Document/dockerfiles
git init
3.对本地仓库内容进行更改(如果是多次对本地的某个仓库进行这样的操作,直接从此步开始即可,不要前面的操作了,因为本地仓库已有具有了github仓库的.git文件了),对更改内容进行提交
git add 更改文件名或者是文件夹名或者是点"\."
git commit -m ’commit内容标注‘
4.本地仓库与github仓库关联
git remote add origin https://github.com/你的github用户名/你的github仓库.git
5.push
git push origin master
6.另外可能用到的命令
git remote rm origin
git pull origin master