1、目录
cd .. //返回上一级目录
ls 或者 dir //查看当前目录下文件夹或者文件
cd /D //进入某一个磁盘如D盘
2、查看工作区代码相对于暂存区的差别
git status
3、提交文件
//将当前目录下修改的所有代码从工作区添加到暂存区 . 代表当前目录
//或者直接选择目标文件(test.txt)
git add .
或者
git add test.text
//将缓存区内容添加到本地仓库
git commit -m "注释"
//将本地版本库推送到远程服务器 master 为远程服务器分支
git push origin master
4、创建SSH key
//查看ssh key 是否存在
cd ~/.ssh
ls
//创建ssh key
ssh-keygen -t rsa -C "你的注册邮箱"
5、建立版本库并提交
//常见目录
mkdir test
//进入该目录
cd test
//初始化
git init
//在github上创建仓库 并复制该地址
//关联本地仓库
git remote add origin 仓库地址
//遇到问题再使用下面命令,清理
git remote rm origin
//将代码由本地仓库上传到 github 远程仓库,依次执行下列语句
//获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)
git pull --rebase origin master
//把当前分支 master 推送到远程,执行此命令后有可能会让输入用户名、密码
git push -u origin master
6、删除文件
//删除本地
git rm -r --cached 文件名
//提交到暂存区
git commit -m "注释"
//提交到远程
git push -u origin master
7、手册
Main Porcelain Commands
add Add file contents to the index
am Apply a series of patches from a mailbox
archive Create an archive of files from a named tree
bisect Use binary search to find the commit that introduced a bug
branch List, create, or delete branches
bundle Move objects and refs by archive
checkout Switch branches or restore working tree files
cherry-pick Apply the changes introduced by some existing commits
citool Graphical alternative to git-commit
clean Remove untracked files from the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
describe Give an object a human reada