2

My project is using git as vcs tool. This question is about the integrated Version Control tool. In development,our branch promise is:

  • Branch master is running to supply stable and formal service.
  • Branch staging is running in a test environment.
  • Developing Branches. If there are new requirements, checkout new branch from master. After developing, we will merge the branch into staging for testing. If new code passes tests, we will merge it into master eventually.

Yesterday, I did such procedures: I found a bug in my project. So I modified some code. But I found the branch is staging.As expected, I stash the code in staging and checkout a new branch B from master. Then I recheckout branch staging and stash pop after which I click IDEA's Panel ↘️ to checkout branch B, IDEA ask me to confirm checkout or not. I chose Smart Checkout then continued my development in new Branch B and made a commit. When I merged B to staging, I cannot find new features from B. I must cherry-pick the commit just from B. Why ? What did Smart Checkout do? It seemed to mark the something as unmodified.

Chuanyi Li
  • 31
  • 1
  • 6
  • [This answer](https://stackoverflow.com/questions/32318824/undo-intellij-smart-checkout) may be helpful. – Koyasha Mar 19 '20 at 15:04

1 Answers1

3

The Intellij idea help page mentions the following about switching between branches:

When multitasking, you often need to jump between branches to commit unrelated changes.

In the Branches popup or in the Branches pane of the Git tool window, select the branch that you want to switch to under Local Branches and choose Checkout from the list of available operations.

What happens next depends on whether there are conflicts between your local changes that you have not committed yet, and the branch that you are going to check out:

If your working tree is clean (that means you have no uncommitted changes), or your local changes do not conflict with the specified branch, this branch will be checked out (a notification will pop up in the bottom-right corner of the IntelliJ IDEA window).

If your local changes are going to be overwritten by checkout, IntelliJ IDEA displays a list of files that prevent you from checking out the selected branch, and suggests choosing between Force Checkout and Smart Checkout.

If you click Force Checkout, your local uncommitted changes will be overwritten, and you will lose them.

If you click Smart Checkout, IntelliJ IDEA will shelve uncommitted changes, check out the selected branch, and then unshelve the changes. If a conflict occurs during the unshelve operation, you will be prompted to merge the changes.

Riyafa Abdul Hameed
  • 7,417
  • 6
  • 40
  • 55