[TFS4]TFS git地址,分支概念

 

1)上传本地代码到TFS

a.Generate Git Credentials,即创建git账户密码

b)上传本地代码

git add *
git commit -m "纳入管理"

git remote add origin https://qiongyan2.visualstudio.com/_git/BeibeiCore2
git push -u origin --all
{{-u参考链接:https://www.zhihu.com/question/20019419/answer/83091592}}
git remote rm origin
Username for 'https://qiongyan2.visualstudio.com': qiongyan2@126.com
Password for 'https://qiongyan2@126.com@qiongyan2.visualstudio.com':

2)git 分支

也可以参考此文:Git 在团队中的最佳实践--如何正确使用Git Flow

作者:khowarizmi
链接:https://www.zhihu.com/question/21995370/answer/33172036
来源:知乎
著作权归作者所有,转载请联系作者获得授权。

写在前面:
1. 建议使用source tree或者其他的gui工具。
2. 安装oh-my-zsh
开始回答问题:
最近在看git关于分支的管理,发现可以用git-flow来管理分支。先贴上项目地址nvie/gitflow · GitHub
git-flow主要有5中分支:master、hotfix、release、develop、feature。
feature分支开始于develop分支,完成以后合并到develop分支。

当完成一定数量feature分支以后,从develop再开一个release分支出来,这些特性将被更新到下一个发布的版本中,之后的feature将不会被合并到release中。

之后在release分支中,只修改bug,然后完成release分支。完成release分支会完成以下三个操作:1、合并release分支到master;2、给master打上版本的标签;3、release回归到develop分支。

当发现master上有bug时,开一个hotfix,完成后合并到master分支。

基本的开发流程就是这样,不清楚的可以看看文档Gitflow Workflow

PS:source tree中已经集成了git-flow使用感受良好

3) Git Flow代码示例

a. 创建develop分支

git branch develop
git push -u origin develop    
b. 开始新Feature开发

git checkout -b some-feature develop
# Optionally, push branch to origin:
git push -u origin some-feature    

# 做一些改动    
git status
git add some-file
git commit    
c. 完成Feature

git pull origin develop
git checkout develop
git merge --no-ff some-feature
git push origin develop

git branch -d some-feature

# If you pushed branch to origin:
git push origin --delete some-feature    
d. 开始Relase

git checkout -b release-0.1.0 develop

# Optional: Bump version number, commit
# Prepare release, commit
e. 完成Release

git checkout master
git merge --no-ff release-0.1.0
git push

git checkout develop
git merge --no-ff release-0.1.0
git push

git branch -d release-0.1.0

# If you pushed branch to origin:
git push origin --delete release-0.1.0   


git tag -a v0.1.0 master
git push --tags
f. 开始Hotfix

git checkout -b hotfix-0.1.1 master    
g. 完成Hotfix

git checkout master
git merge --no-ff hotfix-0.1.1
git push


git checkout develop
git merge --no-ff hotfix-0.1.1
git push

git branch -d hotfix-0.1.1

git tag -a v0.1.1 master
git push --tags

4)本地测试git flow

书本目录:https://git-scm.com/book/zh/v2

qiongyazhudembp:BeibeiCore qiongyanzhu$ git branch --all
* master
  remotes/origin/master
qiongyazhudembp:BeibeiCore qiongyanzhu$

  

$ git branch develop
$ git branch --all
  develop
* master
  remotes/origin/master

  然也可以同步

$ git push -u origin develop:develop
Total 0 (delta 0), reused 0 (delta 0)
To https://qiongyan2.visualstudio.com/_git/BeibeiCore2
 * [new branch]      develop -> develop
Branch develop set up to track remote branch develop from origin.
$ git branch --all
  develop
* master
  remotes/origin/develop
  remotes/origin/master 

  

$ cat .git/refs/heads/master
54b20f4c9f793ad1fc59f4e4b03867c93ad2bca7
$ git checkout develop
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
$ git branch --all
* develop
  master
  remotes/origin/develop
  remotes/origin/master

 

  

远程如果已经有develop分支

 5) 代码编写有误,放弃工作区的修改

$ git diff 工作区与暂存区(提交暂存区,stage)相比的差异

$ git checkout bootstrap.js

原文地址:https://www.cnblogs.com/mspeer/p/6228414.html