command line interface(CLI)常用命令:
格式:command flags arguments
1. pwd : displays the path to the current working directory
例:
TaomatoMacBook-Air:~ Mars$ pwd
/Users/Mars
2. clear :clear out the commands in your current cli window
3. ls :lists files and folders in the current directory
4. ls -a :lists hidden and unhidden files and folers
5. ls -al :lists details for hidden and unhidden files and folders
6. cd :stands for "change directory"
7. cd .. :allows you to change directory to one level above your current directory
8. mkdir : stands for "make directory"
9. touch : creates an empty file
例:touch test_file
10. cp:stands for "copy" cp 有两个参数,第一个参数代表要复制的文件,第二个参数代表要把复制的路径
例:cp test_file Documents
11. cp -r Documents More_docs 带有-r的cp可以复制路径中的内容到其他路径
12. rm :stands for "remove"
13. rm -r More_docs:代表可以移除整个路径和他里面的内容
注意:使用rm -r一定要小心
14. mv :stands for "move"
例:mv new_file Documents
15.使用mv可以重命名文件
例:mv new_file renamed_file
git常用命令
1. 创建版本库的两种方法:
(1)git clone url #克隆远程版本库github
(2)git init #初始化本地版本库
2.修改和提交
- git status #查看状态
- git diff #查看更改的内容
- git add . #跟踪所有该动过的文件
- git add <filename> #跟踪指定的文件
- git mv <old> <new> #文件改名 注意:这个跟CLI命令一样
- git rm <filename> #删除文件 CLI命令
- git rm --cached <filename> #停止跟踪文件但不删除
- git commit -m " message" #提交所有跟踪的文件
git log
4.撤销
git checkout HEAD <filename> #撤销指定的未提交文件的修改内容
5.分支
git branch #显示所有本地分支
git checkout <branch> #切换到指定分支
git branch <new branch> #创建新分支
git branch -d <branch> #删除本地分支
6.合并
git merge <branch> #合并指定分支到当前分支
7.远程操作
- git remote -v #查看远程版本库信息
- git remote add <remote> <url> #添加远程版本库
- git pull <remote> <url> #下载并快速合并
- git push <remote> <branch> #上传并快速合并