1.Git基本工作流程
2.命令
命令 | 作用 |
---|---|
git init | 初始化,创建 git 仓库 |
git status | 查看 git 状态 (文件是否进行了添加、提交操作) |
git add 文件名 | 添加,将指定文件添加到暂存区 |
git commit -m '提交信息' | 提交,将暂存区文件提交到历史仓库 |
git log | 查看日志( git 提交的历史日志) |
历史版本切换:
git reflog
git reset --hard 版本唯一索引值
分支管理操作:
- 创建和切换创建命令:git branch 分支名
切换命令:git checkout 分支名
- 新分支添加文件查看文件命令:ls总结:不同分支之间的关系是平行的关系,不会相互影响
- 合并分支合并命令:git merge 分支名
- 删除分支删除命令:git branch -d 分支名
- 查看分支列表查看命令:git branch
远程仓库工作流程(理解)
杨路恒@WIN-S5E6V36PP3P MINGW64 /d/Java
$ git add 张颖
fatal: not a git repository (or any of the parent directories): .git杨路恒@WIN-S5E6V36PP3P MINGW64 /d/Java
$ git init
Initialized empty Git repository in D:/Java/.git/杨路恒@WIN-S5E6V36PP3P MINGW64 /d/Java (master)
$ git add 张颖
warning: adding embedded git repository: 张颖
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> 张颖
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached 张颖
hint:
hint: See "git help submodule" for more information.杨路恒@WIN-S5E6V36PP3P MINGW64 /d/Java (master)
$ git commit -m '张颖'
[master d755aaf] 张颖1 file changed, 1 insertion(+)create mode 160000 "\345\274\240\351\242\226"杨路恒@WIN-S5E6V36PP3P MINGW64 /d/Java (master)
$ git push -u origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 312 bytes | 312.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.0]
To gitee.com:lhyoungxy/zhangying.git73067e1..d755aaf master -> master
从远程仓库复制到本地仓库:
git clone git@gitee.com:lhyoungxy/zhangying.gitgit pull git@gitee.com:lhyoungxy/zhangying.git