Someone can explain what the difference is:

enter image description here

  • Merge

  • Rebase

  • Branch Default

AND

  • Using stash

  • Using shelve

What is used in what cases?

  • That's what IntelliJ says - Bogdan Shulga

2 answers 2

For starters git stash or git shelve. When you pull up new changes, there may be modified (unfixed) files in your working directory. Naturally, these files can be lost when merging changes. Therefore, git offers them to "hide in your pocket." This is called git stash. After the new code is received from a remote repository, changes from the stash can be rolled back (naturally, and you may need to resolve conflicts). In the "pocket" you can store as many changes as you like (logical - limited to your disk) and the pocket is not transferred to the server. More about git stash in Russian.

git shelve is an ancient project (2008) that is not currently supported. Like git shash, it can hide changes, only in separate branches. Why is it in the studio - do not know.

Now about the first column. When rolling in someone else's commits, two situations can occur - in the branch there are your commits and others and when there is only one side. It is clear that when there are only commits of one side, it is very easy to accept the changes - they just need to be “copied” and corrected pointers to branches.

In the event that there are both own and other people's commits, you need to "add them together." There are two technologies for this - merge and rebase. Merge merges files. Where the files are the same, there are no problems; where the files are different, git tries to put them together. Sometimes it does not work for him and he asks the user to "resolve the conflict" - as only the programmer knows what he wants.

But there is a second way - rebase. Some people love this way, and some fear to destroy the repository, afraid to use it. It works very simply. Two branches are compared and a common ancestor commit is searched. Further, from the local branch, all commits are rolled back to a common commit. Naturally, it is now easy to add commits from a remote repository. After that, local commits "roll over". If conflicts arise during the knurling process, they need to be resolved.

But I don’t know what Branch default is, maybe the studio remembers the last choice and applies it.

  • 2
    Here is found. But for me this is not enough of what Branch Default: choose this option to have the default command for the branch applied. The default command is specified in the branch.<name> section of the .git/config configuration file. says Branch Default: choose this option to have the default command for the branch applied. The default command is specified in the branch.<name> section of the .git/config configuration file. Branch Default: choose this option to have the default command for the branch applied. The default command is specified in the branch.<name> section of the .git/config configuration file. - Bogdan Shulga
  • one
    It says that the desired behavior can be saved in the config (.git / config) - rebase or merge. - KoVadim
  • Curiously, there is no option c --ff-only , which seems to me the most rational. If the master on the server got away with my local one, the situation can be arbitrarily bad, even destructive push -f . Least of all in this situation need a quiet merg without warnings. - Nick Volynkin ♦

I would add that Shelve is a pure IDEA feature https://www.jetbrains.com/idea/help/shelving-and-unshelving-changes.html , something is dead, but git is also not worth it. Here a similar question was https://stackoverflow.com/questions/28008139/git-shelve-vs-stash

  • Looked at this shelve changes. When used, a window appears as if creating a commit, but the result is .idea/shelf/<message> , and inside there is a copy of the document with the removed lines and + the added ones. Some kind of patch format, apparently. - Nick Volynkin ♦