git-up icon indicating copy to clipboard operation
git-up copied to clipboard

Please explain how git solves the current problem?

Open maximveksler opened this issue 8 years ago • 16 comments

Please update README with a section explaining how recent git versions solved this problem

maximveksler avatar Apr 01 '16 08:04 maximveksler

Basically, since Git 2.0, git push with no arguments only pushes the current branch (specifically: the default value for push.default changed from matching to simple). This means it doesn't matter if your other branches are out of date.

I've clarified the paragraph a bit.

aanand avatar Apr 01 '16 15:04 aanand

Thank you.

I believe it would also be valuable to explain how pull changed from merge to rebase ?

maximveksler avatar Apr 01 '16 15:04 maximveksler

I don't believe it did.

aanand avatar Apr 01 '16 16:04 aanand

ok, well in that case your software right still be useful. in my use case git pull does rebase for me, compared to say 4 years ago when I was heavy user of git up that did pull, stash, rebase for me, which is why I needed this tool in the first place..

maximveksler avatar Apr 01 '16 22:04 maximveksler

Here's a one-liner that'll get you a git up that fetches, stashes, rebases and unstashes on just the current branch:

git config --global alias.up '!git fetch && git rebase --autostash FETCH_HEAD'

I've added it to the README.

aanand avatar Apr 29 '16 18:04 aanand

@aanand is there an option to use the git alias above to update all local branches with the remote?

This is, for me, the most useful feature in git-up, so, since the gem isn't going to be maintained anymore, I'm searching for a workaround...

Thanks in advance for the great job done so far!

mauricioklein avatar May 06 '16 16:05 mauricioklein

@mauricioklein I don't have a good solution for that, I'm afraid. The only reason I considered it necessary in the first place was because of the default git push behaviour at the time. Now that that's changed, it doesn't seem that a lot of people need to update all local branches.

aanand avatar May 06 '16 16:05 aanand

I understand. Alright, thanks for the quick explanation. Cheers o/

mauricioklein avatar May 06 '16 16:05 mauricioklein

The alias works for me only on master. If I'm on some other branch it starts to rebase from some other branch, e.g.:

I'm on branch that is 1 day or 10 commits ahead of master. Master has one new commit. The branch's remote and my local copy are up to date. I issue git up Git fetches all branchen. Git starts to rebase my branch on top of some the branch that comes alphabetically first.

In my case it started rebasing on a stale branch called addresses from January.

The alias does not really to what it's supposed to 😕

despairblue avatar May 26 '16 19:05 despairblue

@despairblue Does this work?

$ git config --global alias.up '!git fetch && git rebase --autostash $(git for-each-ref --format "%(upstream:short)" $(git symbolic-ref -q HEAD))'

aanand avatar May 27 '16 13:05 aanand

@aanand that does work! Thanks 🙇

despairblue avatar May 30 '16 10:05 despairblue

Thanks @aanand for the great project when it was needed, and the alias updates now.

harlantwood avatar Jul 20 '16 18:07 harlantwood

PSA: as of Git 2.9, you can just do this:

git config --global alias.up 'pull --rebase --autostash'

aanand avatar Jul 21 '16 16:07 aanand

I'm doing !git pull --rebase --autostash && git log --decorate @{1}..HEAD --pretty=format:'%C(yellow)%h %Cred[%an] %Creset%s' in the "up" alias to emulate the git-up.rebase.log-hook. Do you see any problems with doing it this way or know of a better approach?

EDIT: Ah I just realized if I did "up" twice in a row, it would show me the same log twice instead of just once (the first time)

steven-lai avatar Aug 23 '16 19:08 steven-lai

but actually the git alias doesn't resolve the same problem, right?

Kikobeats avatar Jan 09 '17 10:01 Kikobeats

it does not @Kikobeats . It only updates your current branch. You can try the python port which is still maintained.

jonaswouters avatar Jan 12 '17 10:01 jonaswouters