3

I can commit loads of changes, but nothing gets to github.

Its only when I manually click the PUSH function from the menu that it pushes to github.

How can I get it to do this automatically when I commit?

These are my VS GIT settings:

 // Whether git is enabled
  "git.enabled": true,

  // Path to the git executable
  "git.path": null,

  // Whether auto refreshing is enabled
  "git.autorefresh": true,

  // Whether auto fetching is enabled
  "git.autofetch": true,

  // Confirm before synchronizing git repositories
  "git.confirmSync": true,

  // Controls the git badge counter. `all` counts all changes. `tracked` counts only the tracked changes. `off` turns it off.
  "git.countBadge": "all",

  // Controls what type of branches are listed when running `Checkout to...`. `all` shows all refs, `local` shows only the local branchs, `tags` shows only tags and `remote` shows only remote branches.
  "git.checkoutType": "all",

  // Ignores the legacy Git warning
  "git.ignoreLegacyWarning": false,

  // Ignores the warning when there are too many changes in a repository
  "git.ignoreLimitWarning": false,

  // The default location where to clone a git repository
  "git.defaultCloneDirectory": null,

  // Commit all changes when there are not staged changes.
  "git.enableSmartCommit": false,
torbenrudgaard
  • 2,375
  • 7
  • 32
  • 53

1 Answers1

2

According to this issue on GitHub, this feature does not exist and is not planned to be added.

They suggest using Git hooks to achieve this behavior.

Something like this:

#!/usr/bin/env bash

branch_name=`git symbolic-ref --short HEAD`
retcode=$?

# Only push if branch_name was found (my be empty if in detached head state)
if [ $retcode = 0 ] ; then
    #Only push if branch_name is master
    if [[ $branch_name = "master" ]] ; then
        echo
        echo "**** Pushing current branch $branch_name to origin ****"
        echo
        git push origin $branch_name;
    fi
fi

You can check this answer for more details and options.

victorkt
  • 13,992
  • 9
  • 52
  • 51