WEB-03 GitHub

2020-01-17  本文已影响0人  33jubi

两个文档:

Centralised vs Distributed
Subversion(SVN) => Git

  git config --global user.name "<your-full-name>"
  git config --global user.email "<your-email-address>"
  git config --global color.ui auto
  git config --global merge.conflictstyle diff3
  git config --global core.editor "code --wait"
git init
git clone + 地址    clone该地址文件到本地

(shift+command +. 显示隐藏文件夹 ,看到.git)

git add .
git commit

commit changes

git rm(optional)     相当于remove file后 git add .   
git stash(important!)   相当于暂存在一个栈中
git stash pop  从栈中取出这个缓存

commit message

规范commit message
http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html
Header部分只有一行,包括三个字段:type(必需)、scope(可选)和subject(必需)。

(1)type
type用于说明 commit 的类别,只允许使用下面7个标识。

feat:新功能(feature)
fix:修补bug
docs:文档(documentation)
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试
chore:构建过程或辅助工具的变动

(2)scope
scope用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。

(3)subject
subject是 commit 目的的简短描述,不超过50个字符。

以动词开头,使用第一人称现在时,比如change,而不是changed或changes
第一个字母小写
结尾不加句号(.)

Undo change

git在stage中发生变化

* git checkout  切换分支
* git clean 从你的工作目录中删除所有没有tracked过的文件
* git log:查看版本信息
* git revert :可以revert很久之前的版本
* git reset   :revert跨版本之前的版本必须删除中间的版本

Status and History

* git status: 当前状态
  
* git diff                    :working directory中的变化
  git diff --cashed  

* git log  :查看history
  git log --online --graph --all

细节:

const products =[
  'string',
  'string2',
];

GitHub 常用指令

https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow

https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow

https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

git branch 创建合并分支

master:
branch 1:test

semantic branch names

merge &rebase日常协作

Set up tracking branch

git branch -u <name>/<branch>
也可以在push的时候建立这种联系

Update local from remote

(remote tracking branch: 单纯一个指针,所有和远端产生联系的branch--origin/name)

Delete a remote branch

两种workflow: merge and rebase

git commit
git commit
git commit 

git branch test
git commit
git commit
git checkout test
git commit
git commit
git commit
git checkout 9fced1b
git branch test2
git commit
git checkout test2
git commit
git checkout test
git rebase test

Force push

git push -f
git push <name> +<branch_name>
git push --force-with-lease

Ask git to ignore files(.gitignore)

把一些不需要变化的东西放在.gitignore里

GitHub 团队协作

上一篇下一篇

猜你喜欢

热点阅读