git 初体验

69 阅读1分钟

初次上传项目,新建README.md文件(注意:如果不先提交一下README.md文件,会报错,别的文件也提交不上去)

1、git init
2、git add README.md
3、git commit -m 'first_commit'
4、git remote add origin git@github.com:daijun123/web-learning.git
5、git push origin master

提交单个文件:

1、git add 文件名字
2、git commit -m "备注"
3、git push origin master

提交多个文件:

// 文件之间使用空格隔开
1、git add 文件1名字 文件2名字 文件3名字			
2、git commit -m "备注"
3、git push origin master

提交文件夹:

1、git add 文件夹名字
2、git commit -m "备注"
3、git remote rm origin

回滚操作:

// 查看指定文件的历史版本
git log <filename>
// 回滚到指定commitID
git checkout <commitID> <filename>

删除文件

//  从版本库中删除
git rm test.txt
//  提交
git commit -m "remove test.txt"

更新文件

//  从版本库中更新
git pull

gitk 打开视图窗口