ubuntu下github的使用
身为一个码农,掌握必要的代码管理工具,是必不可少的。这里简单介绍一下github的简单使用过程。
一、注册github账号。
请自行进入https://github.com进行注册。
二、安装git及一些基本设置。
1.安装git
- sudo apt-get install git
- git config --global user.name "your name here"
- git config --global user.email "your [email protected]"
这里“your name here”输入的是你注册github的用户名,这一步是设置你提交时,默认的用户名。
类似的,“your [email protected]”是你注册github账号的邮箱,也可以用别的邮箱,不过用别的邮箱时,需要在github主页上设置里面把用的邮箱添加进去。
3.设置让credential helper 帮助我们在一定时间内在内存中保存我们的code,其中第二行为设置超时的时间
- git config --global credential.helper cache
- git config --global credential.helper 'cache --timeout=3600'
三、建立新的repository
https://github.com/new
四、针对一个新建立的repository的操作(已有项目,跳过此小节,直接看第五节)
1.先建立一个目录,该目录与你新建的repos有关
- mkdir ~/test_project
- cd ~/test_project
- git init //初始化一个空的git repository
- touch README //README 文件用于描述该项目
- git add README
- git commit -m "first commit" //-m 用于指定本次提交的描述信息
- git remote add origin https://github.com//username//test_project.git
提交命令是:
- git push -u origin master
五、已有项目
1. 先clone下来
- git clone https://github.com/username/test_project.git
3.提交
- git add . // .代表添加所有文件
- git commit -m "对文件操作的简易描述"
- git push -u origin master
删除文件:
1、在电脑上新建一个本地仓库repository;
2、使用gitBashHere进入到repoitory中: cd d:/repository;
3、在github上复制你要修改项目的url然后下载到本地仓库: git clone xxxxxxxxx.git;
4、使用gitBashHere进入到你要删除文件的文件夹中: cd d:/aaa/bbb/cc.text;
5、使用: git rm cc.text删除即可;git rm -r src 删除文件夹;
6、运行: git status可以查看你对文件增删改的状态;
7、运行: git commit -m ‘提示信息’ 提交到本地仓库;
8、最后: git push提交到github上,提交过程中需输入你的帐号密码;
9、添加文件到github项目上步骤也一样,只需把git rm 改为 git add即可 。
在README中添加图片:
1、在github上的仓库建立一个存放图片的文件夹,文件夹名字随意。如:img-folder
2、将需要在READNE.md中显示的图片,push到img-folder文件夹中。
3、然后打开github官网,进入仓库的img-folder文件夹中,打开图片
点击红框所示的按钮,copy地址。
4、在README.md中填入:

保存即可。
注:![Image text]这个标识不可缺少,不然就显示文字了。
Image text:指的是如果图片不存在了,要显示的文字说明。