【Python】一键git脚本

使用git bash上传仓库是比较繁琐的,此脚本可以一键将你写好的项目上传到github

配置git环境变量

以下为windows配置方法
找到git的安装路径,将以下路径添加到环境变量

磁盘名称:\...\Git
磁盘名称:\...\Git\mingw64\libexec\git-core
磁盘名称:\...\Git\mingw64\bin

检验是否配置完毕

cmd输入

python
import os
os.system('git')

在这里插入图片描述
若出现上图所示情况,代表配置成功
PS:
1:请在cmd或powershell中输入命令,在Python的原生shell中会只返回1

一键git脚本模块

main.py
可能以后会有更新

import os
import time
__AUTHOR__ == 'Catci'
def updata(description=None,gitsite=None):
	os.system('git init')
	os.system('git add .')
	os.system('git status')
	description = input('please input your Repositories description:\n')
	os.system('git commit -m' + description)
	gitsite = input('please input your Repositories website:\n')
	if gitsite[:19] =='https://github.com/'
		print('website is no wrong')
		os.system('git remote add origin' + gitsite)
		os.system('git push origin master')
		list_ = [i for os.popen(command).readlines() in os.popen(command)]
		if list_[2][:5} == 'error'
			os.system('git pull origin master')
			os.system('git pull origin master')
			print('updata successfully')
		else:
			print('updata successfully')
	else:
		print('your gitsite is wrong,please check it!\nthe right site is https://github.com/....')
		time.sleep(3)
if __name__ == '__main__':
	updata()		
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值