使用bat批处理文件提交Git

相似工具:使用bat批处理文件快速打开Jupyter Lab


使用bat批处理文件提交Git需要我们操作三个文件,新建pull.bat和push.bat,并修改.gitignore。

1. 首先我们在创建rep时候记得添加.gitignore。

2. 我们选择我们可以提交的类型加上 文件类型/

3. 在末尾加上

\pull.bat

\push.bat

4. 在项目文件夹下新建pull.bat,负责把你想要提交的文件pull到“中转站”,这一步实际上离线可以完成,当年想提交后可以双击pull.bat,这时候相当于提交的请求缓存在中转站中


@echo off
title 
D:\Git\bin\git.exe pull origin master
exit

5. 在项目文件夹下新建push.bat,负责把你想要提交的文件从“中转站”push到git上,双击push.bat

@echo off
set /p commit=commit:
title auto commit
D:\Git\bin\git.exe add -A
D:\Git\bin\git.exe commit -m %commit%

D:\Git\bin\git.exe push origin master
D:\Git\bin\git.exe branch -u origin/master master
exit

commit部分一般不会报错,但是后面我自己遇到问题是'master' set up to track remote branch 'master' from 'origin'.

说明我们新建立的master分支还不能和远程的master分支建立追踪关系(虽然表面我们看似已经建立了master分支,但git不认为它和远程的master有任何关系),当然,您可以按照上面提示那样,通过git pull指定远程的分支和本地的分支来进行更新,但此处我们使用提示中的第二种方式,建立本地分支和远程分支的追踪关系:
 

git branch -u origin/master master

到此我们再push就可以发现完成啦!

发布了261 篇原创文章 · 获赞 137 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/weixin_37993251/article/details/102869790