I'm a bit confused about how to use IntelliJ's VCS options correctly.
We're working on a Git repo and I would like to understand how I can do the following in as few steps as possible:
Indeed, if two different persons work on the same class, some times it is obvious that merges should be accepted if the two persons did not work on the same part of the class. Yet so far I've always had to specify the way I wanted the merge to happen in those cases.
I've read a bit about the "Update" option and I'm not sure I really understand what it does exactly. It does the Pull and Merge?
git remote update can update all of your branches set to track remote ones, however it cannot merge any changes in it. git fetch can update only the branch you are on, however not merge any changes in. git pull can update and merge any remote changes of the present branch you are on.
The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes that a "git pull" would bring in. For obvious safety reasons, Git will never simply overwrite your changes.
Generally this is done by merging, i.e. the local changes are merged into the remote changes. So git pull is similar to git fetch & git merge . Rebasing is an alternative to merging. Instead of creating a new commit that combines the two branches, it moves the commits of one of the branches on top of the other.
When comparing Git pull vs fetch, Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn't make any changes to your local files. On the other hand, Git pull is faster as you're performing multiple actions in one – a better bang for your buck.
You're asking 3 different questions, but I'm going to focus on the very last one (Update option).
First, I'd like to point out that the title (Git confusion (“Update” and “Pull”)
) doesn't match with the answer you're looking for. Update
is not a git command -- the update
you're referring to is a feature offered by IntelliJ's git integration, which is a shortcut to an update strategy (merge or rebase).
Each option listed above correspond to an updating strategy:
Use merge update strategy
git fetch
git merge
or
git pull
Use rebase update strategy
git fetch
git rebase
or
git pull --rebase
If you want to know the difference between merging and rebasing, I suggest you read this article: Merging vs. Rebasing.
Use branch default update strategy
The above applies whatever update strategy you have set up in your .git/config
configuration file for the specified branch.
As for Using Stash
and Using Shelve
, I've never used shelve myself, but it seems to be the same as git's stash
except it's managed by IntelliJ instead of git.
NOTE: To specify, if you were fetching the master
branch from your remote repository, you'd need to add origin master
at the end of each commands above (e.g. git pull origin master
, git pull --rebase origin master
).
So to answer your question, Depending on the option you pick, Update
either uses the merge
update strategy (git pull
or git fetch
+ git merge
) or the rebase
update strategy (git pull --rebase
or git fetch
+ git rebase
).
reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With