Sanctriell Sanctriell - 14 days ago 8
Git Question

Git : merging to master branch , add files or pull?

Hello

I am working my codes in Git.
I made an extra branch to work on and I finished my job. Meanwhile, on the master branch new stuff gets added to it.

If I want to keep my work and get the "new stuff" in my branch, It is better to just add the files that I worked on to the master branch or merge my branch to master? After that I just get to do a git pull to have everything together?

Alternative: How I pull only the new or edited files from master branch into my branch without losing any of my work?
Which way is better? I don't want to lose the work in my branch, but I really need to update rest of the code from the master branch to able to keep working.

Answer

You can pull the changes of master branch into your local branch. Then you can create a pull request & merge your branch with master later.

$ git branch                 # show your current branch (* before branch-name)
$ git commit -am <message>   # add & commit your local changes
$ git pull origin master     # pull master into your branch