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

Implement inverse of git push --force #24

Merged
merged 2 commits into from
Jan 23, 2017
Merged

Implement inverse of git push --force #24

merged 2 commits into from
Jan 23, 2017

Conversation

pieterdd
Copy link
Contributor

No description provided.

@@ -624,6 +624,9 @@
# Get the current branch name
branch-name = rev-parse --abbrev-ref HEAD

# Get name of the upstream branch
upstream-name = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. That's a great quick win.

Copy link
Member

@joelparkerhenderson joelparkerhenderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your other change added the upstream-name command. Great idea.

Do you intend for your new reset command to make use of your upstream-name command?

I would expect something like this:

reset-to-upstream = !git reset --hard $(git upstream-name)

Is this what you intend?

It's like git push --force, but in the other direction.
@pieterdd
Copy link
Contributor Author

Yes. I originally chose a different name for the command and I forgot to change the reference to upstream-name there. My bad, I've updated it.

@@ -505,6 +505,7 @@
reset-commit = reset --soft HEAD~1
reset-commit-hard = reset --hard HEAD~1
reset-commit-clean = !git reset --hard HEAD~1 && git clean -fd
reset-to-origin = !git reset --hard $(git remote-branch-name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is remote-branch-name? upstream-name, no?

@joelparkerhenderson
Copy link
Member

Ok good. In git, the "upstream" and "origin" can be different. I'll add the reset-to-upstream command now because it aligns with your upstream-name command. If you want something other than that, can you comment here?

This is a useful item:
http:https://stackoverflow.com/questions/2739376/definition-of-downstream-and-upstream/2749166#2749166

@joelparkerhenderson joelparkerhenderson merged commit fdb3c24 into GitAlias:master Jan 23, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants