git将文件从分支合并到主分支

问题描述 投票:1回答:1

1)我创建了一个分支

$ mkdir newV4
$ git checkout -b newV4
Switched to a new branch 'newV4'
$ cd newV4/

2)创建一个示例文件并将其推送到repo

$touch new.log
$ git add new.log 
$ git status
On branch newV4
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

    new file:   new.log

$ git commit -m "newchange"
[newV4 d1d982d] newchange
 1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 newV4/new.log
$ git push --all
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 300 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/chay24/devops.git
   98a973e..bfa3aa5  master -> master
* [new branch]      newV4 -> newV4

3)与经理合并-----我没有将new.log送到我的主分支

$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ ls
2.log  3.log  4.log  5.log  new  newV  newV2  newV3  test.log
$ git merge newV4
Updating bfa3aa5..d1d982d
Fast-forward
 newV4/new.log | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 newV4/new.log
$ ls
2.log  3.log  4.log  5.log  new  newV  newV2  newV3  newV4  test.log

我想把新文件放到我的主分支中,我该怎么做?

linux git
1个回答
0
投票

你的过程似乎有点不正确..这就是我的工作:

$ git checkout -b hotfix/my-branch -t origin/master
$ mkdir test_folder
$ touch test_folder/test.php
$ git add test_folder
$ git commit -m "adding test"
$ git push -u origin HEAD

这将检查工作树到一个名为hotfix/my-branch的新分支,其中upstream设置为origin/master。做完你的工作之后你就用了

$ git push -u origin HEAD

这会将当前的HEAD推送到您的远程源,使其在全球范围内可用(全局用于有权访问的用户)。

当你想合并时,回到你当地做

$ git checkout master
$ git merge hotfix/my-branch
$ git push -u origin master

一旦推动,这将合并hotfix/my-branchorigin/master

© www.soinside.com 2019 - 2024. All rights reserved.