一. git 设置shadow socks代理
1.设置代理 http/https协议(clone https://前缀的repo会走ss)
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
git config --global --unset http.proxy
git config --global --unset https.proxy
Host github.com bitbucket.org
ProxyCommand nc -x 127.0.0.1:1080 %h %p
[http] proxy = http://127.0.0.1:53325 #lantern proxy [https] proxy = http://127.0.0.1:53325
代理具体长啥样,到network下看proxy
git branch --set-upstream-to=origin/xxx 当前分支与远程分支建立连接
git push --set-upstream origin <branch> 当前分支丢失了upstream后可以这么push上去
git branch -vv 查看本地分支和远程分支的映射
git push origin A:B 本地仓库A推到远端仓库B
git branch -a 查看所有分支,(本地和远端的)
git checkout -b xxx (新建一个本地分支并切换过去,从当前分支拷贝代码)
git checkout -b 本地分支名x origin/远程分支名x(新建本地分支,从远端对应分支拉代码)
git branch -D br(删除本地分支)
git branch -r -D origin/br(删除远程分支)
git log (查看log)
建立远端分支
1.建立本地分支:git branch -b A
2.推送到远端分支:git push origin A:A
查看当前分支
git remote -v
修改远端分支
1.git remote rm origin
2.git remote add origin http://A/B.git
gitlab 如何打tag:
git tag -a V1 -m "V1"
git push origin V1
git stash (当前有修改,想切换分支,最简单的三步:git stash,切换分支,git stash pop)
1. git log
2. git reset --hard 139dcfaa558e3276b30b6b2e5cbbb9c00bbdca96
3. git push origin HEAD --force
记住https的密码:git config --global credential.helper store
五. 一些git错误
1. GitLab: Your account has been blocked.
fatal: Could not read from remote repository.
git 提交时出现以上问题,只用重新设置下远程url即可
$ git remote set-url origin git@yourhost.com:org/project.git
2.push github
remote: Permission to johnzhu12/yeoman-gens.git denied to sparrowzhang28.
fatal: unable to access 'https://github.com/johnzhu12/yeoman-gens.git/': The requested URL returned error: 403
这是因为我pull地址是https的,默认保存了同学的密码,导致不能push了。
方法一:去项目的.git/config下修改url为ssh的 (前提是已经添加了key)
方法二:去mac 的keychain里搜github 把internet password删点,重新,push -v(就是验证下账号密码)
3. SSL certificate problem: self signed certificate
解决方法:git config --global http.sslVerify false
4. 有时候git clone http://host/url.git地址会出现下载不下来,可以
git clone http://account:passwd@host/url.git
再试试
六. github更新fork的仓库
1. Clone your fork:
git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git git fetch upstream
3. Updating your fork from original repo to keep up with their changes:
git pull upstream master