[REQUEST] git push --force
We usually use git commit --amend, which we have to make a git push force. That's something quite common. I think that should be used quite often and I actually see the need.
You can use the custom commands feature to get this. You can read more about it here
Good. What I meant thought is that it should be available by default heh
👍 for making it an easy accessible default. 200+ people at our company use this workflow of amending/rebasing and force pushing.
For what it's worth i use this alias from the command line to be explicit that i push the current branch name to a remote branch with the same name:
alias forcepush='git push --force-with-lease origin $(git_branch_name):$(git_branch_name)'
@akonwi Are you against implementing this? My argument would be that since you did implement commit amending which is often followed by a force push - it would be a useful feature.
I couldn't get the custom command to work :[
I made sure that "Custom Commands" was checked
The following is my full ~/.atom/init.coffee:
# initialization file (not found)
atom.packages.onDidActivateInitialPackages (p) ->
if gitPlus = atom.packages.getActivePackage('git-plus')?.mainModule.provideService()
gitPlus.registerCommand 'atom-text-editor', 'custom-git-commands:undo-last-commit', ->
gitPlus.getRepo()
.then (repo) ->
gitPlus.run(repo, 'reset HEAD~1')
atom.packages.onDidActivateInitialPackages (p) ->
if gitPlus = atom.packages.getActivePackage('git-plus')?.mainModule.provideService()
gitPlus.registerCommand 'atom-text-editor', 'custom-git-commands:push-force', ->
gitPlus.getRepo()
.then (repo) ->
gitPlus.run(repo, 'push --force-with-lease')
@xenithorb Amending a commit is less destructive than force pushing. It's a useful feature with some and a dangerous feature for others. I also force push and I do it via the run command to enforce me to be intentional.
If force pushing was to be implemented in this package, it should be behind a configuration option so users have the chance to opt-in. I'll try to do this soon but if someone else wants to create a pull request, please be my guest.
@xenithorb As far as your init script, you don't need two onDidActivateInitialPackages calls. You can do everything in one block like so
atom.packages.onDidActivateInitialPackages (p) ->
if gitPlus = atom.packages.getActivePackage('git-plus')?.mainModule.provideService()
gitPlus.registerCommand 'atom-text-editor', 'custom-git-commands:undo-last-commit', ->
gitPlus.getRepo()
.then (repo) ->
gitPlus.run(repo, 'reset HEAD~1')
gitPlus.registerCommand 'atom-text-editor', 'custom-git-commands:push-force', ->
gitPlus.getRepo()
.then (repo) ->
gitPlus.run(repo, 'push --force-with-lease')
Making this an opt-in feature makes sense to me. 👍 You should know what you're doing before you use it, but it's a workflow that 200+ devs in my company have adopted to keep a nice clean history that is as "flat" as possible.