0

I forked repo A, I create a branch (new-feature) to make changes and push. I create a pr to repo A, do i need to pull anything before I push new-feature?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Hello Nadi, welcome. Please refer some existing answers of the same subject: https://stackoverflow.com/a/52109096/5506730 – gazdagergo Nov 23 '20 at 07:59

3 Answers3

2

You don't need to pull. You can push an outdated branch to review, and if there are no conflicts it will be rebased when merging. If there are conflicts, the merging will fail.

Having said that, it's usually a good practice to rebase your branch before pushing - just because there are no conflicts it doesn't necessarily mean that it is still logically correct. E.g., imagine you added an argument to a function, and fixed the two places it was used. If someone called it in a third place without this new argument (since it hasn't been introduced yet) there will be no git conflict and your branch could be merged, but it would just be wrong (either the project will fail to compile or you'd get a runtime error, depending on the language being used)

Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

Its not a must its just good practise reason being that if you are working on a project with a number of collaborators it is good to git pull first so that you are aware of any changes and then you can push. By doing this it will be easier in the future to do things like merging, rebasing etc. Believe me its true :)

CartoonZzy
  • 31
  • 5
0

its recommended that you rebase .

https://git-scm.com/book/en/v2/Git-Branching-Rebasing

rebasing help you to be sync with the origin.

Abilogos
  • 4,777
  • 2
  • 19
  • 39