0%

Git Tips

1、有些FQ需要设置代理

设置你自己的IP和host

1
2
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 --list命令查看是否配置成功

移除git代理配置,可以用下面命令

1
2
git config --global --unset http.proxy
git config --global --unset https.proxy

2、.gitignore 不起作用问题的解决

1
2
3
git rm -r --cached .  
git add .
git commit -m "update gitignore"

3、解决Mac下SourceTree每次都让输入密码的问题

1、命令行进入项目目录,输入:
git config –global credential.helper store
2、在source tree更新代码,提示输入密码,输入一次后以后就不需要输入了

4、 Git 合并分支冲突解决过程

Step 1. Fetch and check out the branch for this merge request
git fetch origin
git checkout -b 2.5 origin/2.5 //临时分支
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git fetch origin
git checkout origin/develop //目标分支
git merge –no-ff 2.5 //合并后解决冲突
Step 4. Push the result of the merge to GitLab
git push origin develop //上传合并后的分支

在解决完分支你可以会遇到错误,如下:

解决完的分支push报错

1、git cannot read property fullname of undefined
意思是说你push的分支是一个临时创建的错误冲突分支,你需要去设置head,如图:
右键点击

右键点击分支,create branch here,设置再进行push即可。

有一点需要注意的是: 比如分支A 和分支B 是从master分支出来的,那么你们 A被临时修改紧急BUG之后上线,那么A需要先跟master合并后再让A跟B合并,并解决冲突,这样子,能让master保持是上线的版本。

参考链接:
链接