一、git初始化
git init
二、检测当前文件夹的状态
git status #红色:未被管理的文件 绿色:已经被git管理的文件
三、管理文件
1、管理单个文件
git add 文件名字
2、管理所有文件
git add .
四、个人配置
git config --global user.email "you@example.com" #配置邮箱
git config --global user.name "Your Name" #配置用户名
五、生成文件版本
git commit -m '描述信息'
六、查看版本记录
git log
git reflog
七、回滚指定的版本
git reset --hard 版本 #回滚到暂存区
git reset --head 文件名 #回滚到工作区
八、分支
1、查看目前分支
git branch
2、创建分支
git branch 分支名字
3、切换分支
git checkout 分支名字
4、合并分支
git merge 分支名字
5、删除分支
git branch -d 分支名字
6、分支重命名
git branch -m 分支名字
九、Github上传代码
1、连接远程仓库
git remote add origin 仓库地址
2、推送代码
git push origin 分支
3、拉取代码
git clone 仓库地址
4、本地生成readme文件
git pull --rebase origin 分支
5、拉取更新代码
git pull origin 分支
6、生成代码版本
git tag -a v1 -m '版本描述'
git push origin --tags
十、Github上传大文件
1、安装 Git LFS
下载地址:https://git-lfs.com/
2、初始化:
git lfs install
3、跟踪大文件类型
git lfs track "*.pdf"
十一、整合提交记录
git rebase -i HEAD~最近的记录数量