2017-12-02 回答
下面是一种解决方案 1 把gitbash 的路径放到系统的path环境变量里 我的是 c:\program files (x86)\git\bin 2 这时候 你在系统命令行里就可以用git了 3 在python里倒入 os 模块 然后执行 os.system('git') 就可以了 c:\users\administrator>python python 2.7.8 (default, jun 30 2014, 16:08:48) [msc v.1500 64 bit (amd64)] on win3 type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system('git') usage: git [--version] [--help] [-c <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] the most commonly used git commands are: add add file contents to the index bisect find by binary search the change that introduced a bug branch list, create, or delete branches checkout checkout a branch or paths to the working tree clone clone a repository into a new directory commit record changes to the repository diff show changes between commits, commit and working tree, etc fetch download objects and refs from another repository grep print lines matching a pattern init create an empty git repository or reinitialize an existing one log show commit logs merge join two or more development histories together mv move or rename a file, a directory, or a symlink pull fetch from and integrate with another repository or a local branch push update remote refs along with associated objects rebase forward-port local commits to the updated upstream head reset reset current head to the specified state rm remove files from the working tree and from the index show show various types of objects status show the working tree status tag create, list, delete or verify a tag object signed with gpg 'git help -a' and 'git help -g' lists available subcommands and some concept guides. see 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept. 1 >>>