Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action should use git pull --no-rebase for integrating upstream changes #52

Open
ndonald2 opened this issue Jun 2, 2017 · 4 comments

Comments

@ndonald2
Copy link

ndonald2 commented Jun 2, 2017

Some developers (including myself) prefer to use the "always rebase" configuration option for git pull, which avoids creating superfluous merge commits from un-pushed commits when pulling to a local branch from the same corresponding remote branch. This doesn't cause issues as long as you pull to the same corresponding branch, since the local un-pushed commits don't have remote counterparts yet and commit hashes won't be rewritten.

However, this does cause issues when pulling from a remote branch that is different from the local destination branch, since it's effectively rebasing local changes onto a totally different remote HEAD, which can cause commits to be rewritten.

I propose changing git update and any other command that attempts to pull from a different remote branch to use

git pull origin <upstream_branch> --no-rebase

or alternatively

git fetch origin <upstream_branch>
git merge origin/<upstream_branch>

since that's effectively what the pull should be doing.

@wireframe
Copy link
Owner

@ndonald2 great point. do you think it makes sense as a gitx default or is this more of a user level default?

git config --global pull.rebase true

https://coderwall.com/p/tnoiug/rebase-by-default-when-doing-git-pull

@ndonald2
Copy link
Author

ndonald2 commented Jun 2, 2017

Hmm, I think there's a misunderstanding here. I personally do use the user-level git default for rebase pulling, as you described.

The issue is that gitx's current implementation doesn't take that into account - it uses whatever the user level default is for pulling, which breaks things if the default is rebase pulling. In the case of git update, the assumption as-implemented is that pulling from an upstream branch (e.g. pulling master into the current feature branch) will cause a merge, which does not hold true for the case when the default pull configuration uses rebasing.

I'm suggesting to change the gitx command invocations to forcibly opt-out of rebase pulling, using either method I described.

@ndonald2
Copy link
Author

ndonald2 commented Jun 2, 2017

I might actually take a stab at a pull request for this. It would be a good ruby refresher :)

f1sherman added a commit to f1sherman/gitx that referenced this issue Feb 6, 2024
As described in wireframe#52, when the
developer has `pull.rebase = true` in their git config, they will get an
error when updating due to git attempting to rebase local changes on top
of a different remote HEAD. The error can unfortunately be fairly opaque
and confusing (e.g. `Updates were rejected because the tip of your
current branch is behind`). This fixes the issue by doing a plain merge
instead of a rebase.
This was referenced Feb 6, 2024
@f1sherman
Copy link
Contributor

Fixed in #72

stephendavidgregory added a commit to stephendavidgregory/rstudio_and_git that referenced this issue Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants