[英]How to create local private git branch from a remote repo?
I am from perforce background.我来自 perforce 背景。 Now I have moved to a new team where we are using GIT and I use a Windows 7 box.
现在我搬到了一个使用 GIT 的新团队,我使用的是 Windows 7 机器。
As per our branching strategy we create a new branch for every feature from a branch called 'develop'.根据我们的分支策略,我们为名为“develop”的分支中的每个功能创建一个新分支。 So for us develop is like the trunk in perforce/svn from where I would like to keep merging into local branch at regular interval.
所以对我们来说,开发就像 perforce/svn 中的主干,我想定期合并到本地分支。
This is I what I am trying to achieve: Create my private branch, say 'develop-user-private'.这就是我想要实现的目标:创建我的私有分支,比如“开发用户私有”。 Being in a new team I will do a lot of research(dummy code changes to understand the application logic while debugging) in this branch.
在一个新团队中,我将在这个分支中做很多研究(虚拟代码更改以在调试时理解应用程序逻辑)。 Therefore, I will not push anything back to server but only commit to local repo.
因此,我不会将任何内容推送回服务器,而只会提交到本地存储库。 I only want this branch on my local machine but do not want it on server, I mean only a private local branch.
我只希望在我的本地机器上有这个分支,但不希望在服务器上有它,我的意思是只有一个私有的本地分支。
This is what I did这就是我所做的
cd c:\\GitRepo
cd c:\\GitRepo
git init
混帐初始化
git clone https://user@gitrepourl
git 克隆https://user@gitrepourl
Upto this it looks good based on the readings I have done.到目前为止,根据我所做的阅读,它看起来不错。 Now when I run
现在当我跑
git branch develop-user-private
git 分支开发-用户-私有
it fails with error它因错误而失败
"fatal: Not a valid object name: 'master' "
“致命:不是有效的对象名称:'master'”
Questions:问题:
How to create this local private branch from 'develop'?如何从“开发”创建这个本地私有分支?
What will be the command to take(merge) latest from 'develop' into this new branch?从“开发”中获取(合并)最新到这个新分支的命令是什么?
Git will not create a master branch until you commit something.在你提交一些东西之前, Git不会创建一个 master 分支。 As suggested in the comments,
init
is not required when cloning.正如评论中所建议的,克隆时不需要
init
。
cd <repository-name>
cd <repository-name>
git branch <local-branch-name>
git branch <local-branch-name>
git commit -am "commit message"
git commit -am "commit message"
git checkout master
git checkout master
git pull origin master
git pull origin master
git merge <local-branch-name>
git merge <local-branch-name>
git push origin master
git push origin master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.