avatar

Catalog
Git常用操作整合

github远程托管文件 非常的方便。git操作种比较多的就是本地文件推送到远程,仓库等。而我一直也是没有搞明白,github本地文件远程推送是如何操作的,以至于今天卡了很久,来记录一下。

git

git推送本地文件

一般流程

Note : 默认远程仓库是空的

bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 1.新建远程仓库 ,这个可以自己去查阅,很容易

# 2.把本地需要推送的文件夹设置为git仓库
git init

# 3.添加文件
git add .

# 4.提交文件
git commit -m 'first_commit'

# 5.添加镜像源
git remote add origin https://github.com/fryddup/fryddup.github.io.git

# 6.推送文件
git push -u origin master

同步问题

以上代码即可实现本地文件推送到远程,但是注意当仓库不是空的,仓库有改动,应当如下操作:

bash
1
2
3
4
5
6
7
git add .

git commit -m 'first_commit'

git pull #注意,此命令即是远程文件同步到本地。

git push -u origin master

git 代理相关

设置代理

bash
1
2
git config --global http.proxy 'socks5://127.0.0.1:根据vpn选择端口号' 
git config --global https.proxy 'socks5://127.0.0.1:根据vpn选择端口号'

git代理设置相关的东西,实际上应该根据自己的vpn选择开哪一种代理。ssr用sock5代理是可以的,但是clash 需设置成http代理。代理的端口号要根据vpn来设置,并不是通用的。

查看代理

bash
1
2
git config --global --get http.proxy
git config --global --get https.proxy

取消代理

bash
1
2
git config --global --unset http.proxy
git config --global --unset https.proxy
Author: realLiuSir
Link: http://yoursite.com/2020/02/02/git%E6%8E%A8%E9%80%81%E6%96%87%E4%BB%B6/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Donate
  • 微信
    微信
  • 支付寶
    支付寶