Skip to content

Instantly share code, notes, and snippets.

@pockry
Last active February 4, 2016 10:47
Show Gist options
  • Save pockry/7ed70f153e754573ad71 to your computer and use it in GitHub Desktop.
Save pockry/7ed70f153e754573ad71 to your computer and use it in GitHub Desktop.

##初始配置

  • git config --global user.name "pockry"
  • git config --global user.email [email protected]

##个人开发

  1. git托管服务上创建repo
  2. git clone
  3. 本地开发
  4. git add -A注意使用git add .将不暂存删除的文件
  5. git commit -m "提交原因"
  6. 可选:git tag -a v0.1.0 -m "feature", git push origin v0.1.0:v0.1.0
  7. git push origin master

可选:

  • 添加远端:git remote add shortname url
  • 防手滑回滚:git checkout <filename>
  • 放弃本地所有修改:git fetch origingit reset --hard origin/master

###切换环境开发

  1. git pull origin master
  • 务必先pull后开发,如果先动了本地文件,pull会失败,此时执行下面命令:
  • 只修改了少数文件: 回滚git checkout <filename>
  • 修改很多:放弃本地所有修改git fetch origingit reset --hard origin/master
  1. ->个人开发步骤3

##团队协作

It depends.

###向别人主导的项目贡献代码(无merge权限)

  1. 提issue或者联系作者,讨论某一个问题
  2. 提出可fix或添加feature,可pull request
  3. 对方同意后,fork项目
  4. git clone
  5. git branch branch_name
  6. 本地开发测试
  7. git push origin branch_name:branch_name
  8. 向别人的项目pull request
  9. wait for result.

###项目是自己创建的(有merge权限)

  1. 将项目尽量模块化,减少潜在的开发冲突
  2. team member有提交代码权限
  • 创建dev分支git branch dev
  • 切换分支git checkout dev or合并两命令git checkout -b dev master
  • 分配任务,注意不出现冲突
  • 负责代码审核、merge和测试git checkout devgit merge branch_name
  • release master分支git checkout mastergit merge devgit tag -a 0.1.0 -m "ver0.1.0"
  1. 无提交代码权限(Github例)
  • 规范流程 -> 向别人主导的项目贡献代码
  • 讨论问题
  • 允许pull request
  • merge

可选:

  • 删除分支git branch -d branch_name不能删当前分支,强删-D可删未合并分支
  • 重命名分支git branch -m oldname newname强制-M
@voiceshen
Copy link

Do you try to use git to send email use outlook.com? If possible, can you share the configuration for the smtp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment