Git版本控制

社会主义新天地 提交于 2020-01-30 00:17:06

Update :20191024


问题:

  1. 为什么要使用git,有哪些应用
  2. 是否有过软件项目开发经验
  3. 是否经常与人合作,共同开发软件

Git 的历史

Wiki的解释:

Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals includes speed, data integrity, and support for distributed, non-linear workflows.

Git 的应用

  1. 去中心化
  2. 分布式
  3. 分支策略

Git的工作区域

  1. WorkSpace(工作目录)
  2. Index(暂存区)
  3. Repository(资源区 - .git)
  4. Remote(git 的远程仓库)

Git的工作流程

git工作流程图

图片来源于网络,仅用于解释Git的工作流程

Git的常用命令

在这里插入图片描述

git commit -a

  • git-commit : record changes to the repository
  • git-pull
  • git-push
  • git rebase
  • git branch
  • git merge
  • git fetch

远程分支
基于远程分支快速合并

git remote update -p
# git fetch --all -p
git rebase master | origin/master

Git commit questions

Q: Unmerged paths
A: 修改冲突的文件
Q: Untracked files
A: git reset --head HEAD

Git 的面试题

  1. git push origin master 这个指令在做些什么事情
  2. git clone, git fetch, git pull 三者的区别
  3. git 中 head 的是什么
  4. 合并分支与删除分支 发生了什么事情
  5. git diff 是做什么用的
  6. git 中为什么要使用标签
  7. rebase合并与一般合并有什么不同
  8. 合并分支发生冲突时, 应该如何解决
  9. git checkout SHA1, git reset SHA1, git revert SHA1三个指令有什么不同
  10. 如果不小心把还没有合并的develop分支删掉了,该怎么办
  11. git reset --hard 指令把档案处理掉了,有机会救回来吗?

Ubuntu Git log 管理工具

More information is :
conventional-changelog
cz-conventional-changelog

A commitizen adapter for the angular preset of https://github.com/conventional-changelog/conventional-changelog

sudo npm install -g commitizen
sudo npm install -g conventional-changelog-cli
sudo npm install -g cz-conventional-changelog
sudo npm install -g conventional-changelog

配置:

echo '{"path": "cz-conventional-changelog"}' > ~/.czrc

oh-my-zsh

oh-my-zsh/wiki/Cheatsheet

alias command
g git
gb git branch
gc git commit -v
gco git checkout
gst git status
gst git status
gloga git log --oneline --decorate --graph --all
glgp git log --stat -p
glgg git log --graph

参考

  1. Git版本控制的原理
  2. git 面试题
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!