Skip to content

Conversation

@kumon
Copy link
Contributor

@kumon kumon commented Jan 13, 2016

This command syncs local branch with remote branch.

This runs:

git fetch <remote-name> <branch-name>
git reset --hard <remote-name>/<branch-name>
git clean -d -f -x

bin/git-sync Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

help can be a legal name of a remote branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reviewing it. I should fix that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As we don't use "?" for seeing usage with any other commands, we shouldn't do it here either.
? is a special character in some terminals with extglob (i think) enabled, and could confuse people as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove '?'. Thank you!

@spacewander
Copy link
Collaborator

What about using a default remote/branch when remote/branch argument is missing?
Just follow the convention of git fetch/pull.

@kumon
Copy link
Contributor Author

kumon commented Jan 13, 2016

I will follow the convention of git fetch/pull. It's more practical. Thank you so much.

@kumon
Copy link
Contributor Author

kumon commented Jan 15, 2016

I changed to use upstream of local branch by default, when remote/branch is not specified.

bin/git-sync Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

A little quibble:
git rev-parse --abbrev-ref --symbolic-full-name @{u} will return nothing if there is not related upstream branch.
Then users will see ... & sync with ''? [y/N] and the command may simply reset to current branch, which is not really wanted.

@kumon
Copy link
Contributor Author

kumon commented Jan 16, 2016

I added upstream check that is based on exit status of git rev-parse --abbrev-ref --symbolic-full-name @{u}.

@spacewander
Copy link
Collaborator

@hemanth @qw3rtman
It looks good to me. What about your idea?

@qw3rtman qw3rtman added this to the 4.1.0 milestone Jan 17, 2016
qw3rtman added a commit that referenced this pull request Jan 17, 2016
@qw3rtman qw3rtman merged commit 98d0d8c into tj:master Jan 17, 2016
@qw3rtman
Copy link
Collaborator

Yup, looks good to me! Merging.

In the future, I think it'd be a good idea to standardize how help/usage is displayed for each command. Each command should have the same name for the function that displays the help/usage. Additionally, the formatting of the usage should be the same.

@kumon
Copy link
Contributor Author

kumon commented Jan 17, 2016

Thank you for reviewing it!

@qw3rtman
Copy link
Collaborator

Thanks for contributing, @kumon! 😄

tardypad pushed a commit to tardypad/git-extras that referenced this pull request Jul 13, 2016
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.

4 participants