简体   繁体   中英

What is the risk to pull directly from remote develop branch in IDE if only working on local feature branch

If using modern IDE like IntelliJ or Eclipse and working on a local feature branch, is it ok to directly pull changes from origin/develop branch to sync latest changes instead of checkout and pull latest develop branch to do a merge locally? I think common IDE can do merge smartly and even if there is conflict, it has to resolve it manually anyway.

I can see the checkout develop-- pull -- merge from feature branch adopt the git workflow from command line mode and doing the merge locally, however if developer only care about local feature branch, is it necessary to have extra route to get fresh version of the develop branch locally?

There's no "risk" involved in pulling changes from origin/develop directly into your local feature branch without first updating your local develop branch. However, there are a couple things you should keep in mind:

  1. Do a pull rebase instead of a regular merge
  2. When you compare your local feature branch with your local develop branch, the former is going to contain commits that you didn't make, but that instead came from origin/develop

Here's an example that illustrates this scenario:

o---o develop
     \
      A---B---C feature

o---o---D---E origin/develop

Once you pull in the commits from origin/develop directly into feature , either from the IDE (make sure you enable the rebase option) or with git pull -r origin develop , the branch is going to look like this:

o---o develop
     \
      D---E---A'---B'---C' feature

o---o---D---E origin/develop

Now, if you compare feature with the local develop , it's going to look like commits D and E were created in the feature branch, while, in reality, they came from origin/develop .

Of course, once you sync your local develop with origin/develop , everything is going to look like you expect:

o---o---D---E develop
     \
      A'---B'---C' feature

o---o---D---E origin/develop

I wrote a blog post that explains why the default git pull with a shared branch leads to a more complicated history.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM