简体   繁体   English

需要有关使用远程 git repo 的建议

[英]Need advise about working with remote git repo

I have git situation like below and im new to git too :我有如下 git 情况,我也是 git 新手:

  • On remote we have Development branch and i have cloned it在远程我们有开发分支,我已经克隆了它
  • I have checkout Development and create new Branch called A01我有结帐开发并创建名为 A01 的新分支
  • I have done Push the branch A01 and create Pull Request on A01我已经完成推送分支 A01 并在 A01 上创建拉取请求
  • A01 reviewed and merge to remote Development repo A01 审查并合并到远程开发仓库
  • I do made some changes in Projects file but for local environment only (not pushed)我确实在项目文件中做了一些更改,但仅适用于本地环境(未推送)

What should i do if i have to create new branch (ex:A02) to implement new feature In my thinking there are 2 options :如果我必须创建新分支(例如:A02)来实现新功能,我该怎么办在我看来,有两个选项:

  • Merge local Development br with A01 br将本地开发 br 与 A01 br 合并
  • Git pull for Development branch(remote) (but when i do this, some msg showing : The pull would overwrite your local changes to the following 2 files ... )用于开发分支的 Git 拉(远程)(但是当我这样做时,一些消息显示:拉将覆盖您对以下 2 个文件的本地更改......)

Please advise, appreciate your help.请指教,感谢您的帮助。

I do made some changes in Projects file but for local environment only (not pushed)我确实在项目文件中做了一些更改,但仅适用于本地环境(未推送)

What you need to do depends on what you want to do with your local changes.您需要做什么取决于您想对本地更改做什么。

You don't want your local changes to be part of any remote branch.您不希望本地更改成为任何远程分支的一部分。

  • Do git stash .git stash This will clear your working tree and index tree in your repo这将清除您的回购中的工作树和索引树
  • Do git pull .git pull It should complete successfully.它应该成功完成。
  • At later point, when you want these changes back you can do git stash apply .稍后,当您想要恢复这些更改时,您可以执行git stash apply Remember, you might get merge conflict while applying it back.请记住,在应用它时您可能会遇到合并冲突。 You need to resolve them.你需要解决它们。

You want your local changes to be part of develop branch (remote as well) immediately您希望您的本地更改立即成为开发分支(也是远程)的一部分

  • Stage and commit your local changes.暂存并提交您的本地更改。
  • Then execute git pull .然后执行git pull You might get merge conflict, you need to resolve them.您可能会遇到合并冲突,您需要解决它们。

You want your local changes to be part of remote branch but not for now.您希望您的本地更改成为远程分支的一部分,但现在不是。

One option is to create a new branch to track your local changes.一种选择是创建一个新分支来跟踪您的本地更改。

  • Run, git checkout -b <new branch name>运行, git checkout -b <new branch name>
  • git checkout develop
  • git pull
  • Later when you want to work on your local changes, you can do git checkout <new branch name>稍后当您想要处理本地更改时,您可以执行git checkout <new branch name>

Another option,另外一个选项,

  • you can commit your changes to local develop branch.您可以将更改提交到本地开发分支。
  • you can create A02 out of remote branch directly as git checkout -b A02 origin/develop (Assuming your remote repo name uses the default name, origin.)您可以直接从远程分支创建 A02 作为git checkout -b A02 origin/develop (假设您的远程仓库名称使用默认名称 origin。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM