我该如何将我的Python Spyder连接到GitHub?

57

有没有办法将python spyder与github连接起来?

我通过github管理我的R脚本,因为R提供了接口,使用户可以提交、拉取和推送,但我想知道是否有同样(或类似)的系统在python(x,y)spyder中。

我想使用github来管理我的Python脚本,而不仅仅是在本地编辑我的代码,并每次手动编写更改日志。

3个回答

38

Spyder已经集成了命令行git。

https://github.com/spyder-ide/spyder/issues/6105

First right click the tab corresponding to any file in your repository and click "set console working directory."

Then go to the Ipython window in Spyder and simply type your git commands (assuming Git is installed and its paths are configured properly) but append a "!" to the beginning of your command:

!git add "file.py"
!git commit -m "My commit"
!git push origin master

有没有关于 "!" 特性如何工作的文档,我找不到任何资料? - Dick McManus
https://jakevdp.github.io/PythonDataScienceHandbook/01.05-ipython-and-shell-commands.html - Drew
1
@DickMcManus "!"只是IPython中运行shell命令的转义字符,参见https://jakevdp.github.io/PythonDataScienceHandbook/01.05-ipython-and-shell-commands.html。 - Drew

22

(Spyder的开发人员在此) 很抱歉,目前(2017年2月)Spyder和Git/Github之间没有集成。

此外,还没有具体计划添加这种支持。我们可能需要一年或一年半的时间来实现。

Github上相关问题链接:https://github.com/spyder-ide/spyder/issues/816


11
+1 @betontalpfa。对我来说,我想通过Spyder ipython控制台将本地文件放入现有的Github.com存储库中。

因此,我没有点击“设置控制台工作目录”,而是在Spyder中的ipython控制台中执行了以下操作(我使用的是Mac OSX Mojave,并已从Appstore安装了Xcode):

  • 将工作目录初始化为git目录

    !git init
    
  • 拉取现有存储库以与您要推送的文件合并

  • !git remote add origin https://github.com/myUserName/sample.git
    
  • 将该文件添加到本地Git

  • !git add temp.py
    
  • 将文件推送到github.com

  • !git push -u origin master
    

我认为答案很好。它只是使用Spyder中的终端与git进行交互。 - SriK

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接