是否有可能在自动提交后进行git push?现在我需要在手动提交后点击push,这不是很舒服.
更新2018-12-20
最新版本的VS Code具有在提交时推送或同步的设置.
转到VS代码设置菜单(左下角的齿轮>设置)
搜索 git.postCommitCommand
选择你的选择
旧的解决方法
我也想念这个.这是目前的"解决方法" -
code .git/hooks/post-commit
复制并粘贴以下内容 -
#!/usr/bin/env bash branch_name=`git symbolic-ref --short HEAD` retcode=$? non_push_suffix="_local" # Only push if branch_name was found (my be empty if in detached head state) if [ $retcode = 0 ] ; then #Only push if branch_name does not end with the non-push suffix if [[ $branch_name != *$non_push_suffix ]] ; then echo echo "**** Pushing current branch $branch_name to origin [i4h_mobiles post-commit hook]" echo git push origin $branch_name; fi fi
确保它是可执行的 -
chmod +x .git/hooks/post-commit
再试一次.
Creds:
如何在git中提交后自动推送?
发布提交挂钩未运行
提交#14885时添加自动推送选项