Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Discourage (prevent?) use of push --force #94

Open
salcode opened this issue Dec 26, 2018 · 1 comment
Open

Discourage (prevent?) use of push --force #94

salcode opened this issue Dec 26, 2018 · 1 comment

Comments

@salcode
Copy link
Member

salcode commented Dec 26, 2018

While we have added aliases to make it easier to use push --force-with-lease instead of push --force (see both #10 and #71), I would like go so far as to prevent push --force.

I've not determined a way to do this with a git alias (since I don't see a way to map a current command, i.e. git push, to something else).

I think the best route may be to create a bash script that runs in place of git. The script would listen for push --force and intervene in that situation, otherwise it would pass along all commands to git.

salcode added a commit that referenced this issue Dec 26, 2018
This script should be executible and aliased to git.
If someone tries to use `git push --force` it prevents them, otherwise
it calls the real copy of git with the same parameters.

See #94
salcode added a commit that referenced this issue Dec 26, 2018
By aliasing "git" to this script, we can add our own checks before
git does anything.

e.g. We can check if the user is trying to use
git push --force
and present them with an error message and explanation on why
it is a bad idea.

Once our checks are based, this script calls the real git program and
passes in the same parameters.

See #94
salcode added a commit that referenced this issue Dec 26, 2018
salcode added a commit that referenced this issue Dec 26, 2018
By aliasing "git" to this script, we can add our own checks before
git does anything.

e.g. We can check if the user is trying to use
git push --force
and present them with an error message and explanation on why
it is a bad idea.

Once our checks are based, this script calls the real git program and
passes in the same parameters.

See #94
salcode added a commit that referenced this issue Dec 26, 2018
salcode added a commit that referenced this issue Dec 26, 2018
By aliasing "git" to this script, we can add our own checks before
git does anything.

e.g. We can check if the user is trying to use
git push --force
and present them with an error message and explanation on why
it is a bad idea.

Once our checks are based, this script calls the real git program and
passes in the same parameters.

See #94
salcode added a commit that referenced this issue Dec 26, 2018
@salcode
Copy link
Member Author

salcode commented Dec 26, 2018

I'm testing out some code to add this git push --force prevention behavior. It is on branch sf/prevent-push-force-94.

I'll use it in my everyday use for a bit and if I'm happy with it, I'll create a PR to merge this functionality.

salcode added a commit that referenced this issue Jan 11, 2019
By aliasing "git" to this script, we can add our own checks before
git does anything.

e.g. We can check if the user is trying to use
git push --force
and present them with an error message and explanation on why
it is a bad idea.

Once our checks are based, this script calls the real git program and
passes in the same parameters.

See #94
salcode added a commit that referenced this issue Jan 11, 2019
salcode added a commit that referenced this issue Jan 15, 2019
By aliasing "git" to this script, we can add our own checks before
git does anything.

e.g. We can check if the user is trying to use
git push --force
and present them with an error message and explanation on why
it is a bad idea.

Once our checks are based, this script calls the real git program and
passes in the same parameters.

See #94
salcode added a commit that referenced this issue Jan 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant