【问题标题】:VScode will not auto push when I commit changes当我提交更改时,VScode 不会自动推送
【发布时间】:2017-06-09 09:17:37
【问题描述】:

我可以提交大量更改,但没有任何内容可以访问 github。

只有当我从菜单中手动单击 PUSH 功能时,它才会推送到 github。

如何在我提交时让它自动执行此操作?

这些是我的 VS GIT 设置:

 // 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,

【问题讨论】:

    标签: github visual-studio-code


    【解决方案1】:

    根据 GitHub 上的this issue,此功能不存在,不打算添加。

    他们建议使用Git hooks 来实现此行为。

    类似这样的:

    #!/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
    

    您可以查看this answer 了解更多详情和选项。

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 2014-12-01
      • 2013-09-04
      • 1970-01-01
      • 2017-04-23
      • 2018-07-09
      • 1970-01-01
      • 2010-10-09
      • 1970-01-01
      相关资源
      最近更新 更多