Git学习笔记
Git是什么?
- Git是目前世界上最先进的分布式版本控制系统(没有之一)。
shell命令
- pwd
- ls
- ls -la
- cd
- cd .
- cd ..
- cd ~
- cd /
- mkdir
- touch
- rm
- clear
配置用户名和邮箱
- git config --global user.name '王令'
- git config --global user.email '2603820757@qq.com'
- git config --list
- git config user.name
- git help
管理git项目
$ git init git01
$ cd git01
$ touch index.html
$ git status
On branch master
No commits yet
Untracked files: -- 未被追踪
(use "git add <file>..." to include in what will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
$ git add index.html
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
commit作用
- git commit
- git commit -m
- git commit -am
log追踪
- git log
- git log -p -2
- git log --author
- git log --oneline
- git log --graph
- git log --pretty=oneline
- git log --pretty=format
版本管理
$ git reset --hard HEAD^
$ git reflog
$ git reset --hard c41e801
建立切换删除分支
- git branch 查看分支
$ git branch develop * master
- git branch [name]
$ git branch develop
创建分支 - git checkout [branch name]
$ git checkout develop
切换分支 - git checkout -b [branch name]
$ git checkout -b business
创建并切换分支 - git branch [name] -d
- git branch [name] -D
如何解决合并时发生的冲突
- git merge [branch name]
- git status 查看冲突原因
- git merge --abort 终止合并
- 手动选择正确内容
- git commit
通过命令查看版本线图
- git log
- git log --oneline
- git log --oneline --graph
- git log --oneline --graph --all
- git log --oneline --graph -[number]
快转机制的意义
- 快转实际上就是当前master的将来时
- git merge branchname --no-ff
注册GitHub账号
挣钱养媳妇儿^.^