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

Custom Commands Snippets

Akonwi Ngoh edited this page Jan 3, 2019 · 3 revisions

Custom commands can be done using this template in your init file.

atom.packages.onDidActivateInitialPackages(() => {
  const gitPlus = atom.packages.getActivePackage('git-plus')
  if (gitPlus) {
    const gp = gitPlus.mainModule.provideService()
    // commands go here, see below
  }
})

Commands

Please feel free to add commands you use

Unstage The Last Commit

gp.registerCommand('atom-text-editor', 'akonwi:unstage-last-commit', () => {
  gp.getRepo().then(repo => gp.run(repo, 'reset HEAD~1'))
})

Update Last Commit

gitPlus.registerCommand 'atom-text-editor', 'akonwi:update-last-commit', ->
      gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use
      .then (repo) -> gitPlus.run repo, 'commit --all --amend --no-edit'

Push --force-with-lease

    gitPlus.registerCommand 'atom-text-editor', 'akonwi:use-the-force', ->
      gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use
      .then (repo) -> gitPlus.run repo, 'push --force-with-lease'

Rebase --continue

    gitPlus.registerCommand 'atom-text-editor', 'akonwi:rebase-continue', ->
      gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use
      .then (repo) -> gitPlus.run repo, 'rebase --continue'

Rebase --abort

    gitPlus.registerCommand 'atom-text-editor', 'akonwi:rebase-abort', ->
      gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use
      .then (repo) -> gitPlus.run repo, 'rebase --abort'

Checkout Previous commit

    gitPlus.registerCommand 'atom-text-editor', 'akonwi:checkout-to-previous', ->
      gitPlus.getRepo()
      .then (repo) -> gitPlus.run repo, 'checkout head~'
Clone this wiki locally