• Uncategorized

About linux : git-merging-the-files-from-the-branch-to-master

Question Detail

1) I have created a branch

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

2) creating a sample file and pushing it to the 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) Merging with the manger —– I am not getting the new.log to my master branch

$ 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

I want to get the new file into my master branch, how can I do that?

Question Answer

your process seems a little incorrect.. here’s what I do:

$ 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

this will checkout the working tree to a new branch called hotfix/my-branch with an upstream set to origin/master. After doing your work you use

$ git push -u origin HEAD

this pushes the current HEAD to your remote origin, making it available globally (globally as in, to those who have access).

when you want to merge, come back to your local and do

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

this will merge hotfix/my-branch into origin/master once pushed.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.