当前位置:   article > 正文

git如何把master的内容更新到分支_idea git更新master到分支

idea git更新master到分支

当有人对master进行更新之后,你想让已经创建的分支内容更成master的最新状态,

bpan@5CG7022BM2 MINGW64 /d/GitRep/JIRA_Extensions (master)
$ git checkout 20180315  //切换到分支下
Switched to branch '20180315'
Your branch is behind 'origin/master' by 17 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

bpan@5CG7022BM2 MINGW64 /d/GitRep/JIRA_Extensions (20180315)
$ git merge master  //合并master分支代码到当前分支:
Updating cee69ca..8b0ec9a
Fast-forward
 .gitignore                                         |   2 +
 .../functions/ExtractGroupMembersToExcelFile.java  | 225 +++++++++++++++++++++
 2 files changed, 227 insertions(+)
 create mode 100644 src/main/java/com/nokia/jira/functions/ExtractGroupMembersToExcelFile.java

bpan@5CG7022BM2 MINGW64 /d/GitRep/JIRA_Extensions (20180315)
$ git status
On branch 20180315
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

bpan@5CG7022BM2 MINGW64 /d/GitRep/JIRA_Extensions (20180315)
$ git push origin 20180315  //push到远程分支
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': 962720900
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/962720900/JiraExtensionFunctions.git
   e713274..8b0ec9a  20180315 -> 20180315
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

这将把master分支最新的提交合并到目标分支中。如果出现冲突,需要手动解决冲突后再提交。

另外,如果只需要更新分支上的某个文件或文件夹,可以使用以下命令:

  1. 切换到目标分支:
    git checkout 分支名

  2. 使用checkout命令将master分支上的文件或文件夹更新到目标分支:
    git checkout master 文件路径

这将使用master分支上最新的版本替换目标分支上的文件或文件夹。

需要注意的是,使用以上命令后,需要手动提交更改到目标分支,使用以下命令提交更改:
git add . “存放暂存区”
git commit -m "update" “存放本地库”
git push origin lijia “更新master分支内容到分支”

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/673228
推荐阅读
相关标签
  

闽ICP备14008679号