git常见用法
查看分支是从哪开的
git reflog --date=local | grep $branch_name
清除文件的追踪记录
git rm --cached $file
git rm -r --cached $dir
回退到某一次commit
git reset --hard $ID
回退到上一次拉取
git reflog
git reset --hard $ID
暂存
git stash save “temp save”
// atfer some actions on other branch
git stash pop
但是切换到master 小程序无法编译了
git分支合并到主干,只保留一条合并记录
git checkout master
git merge --squash $branch
git commit -m “branch完成,合并到主干”
Automatic merge failed; fix conflicts and then commit the result.
拉取origin master 和 本地分支 自动合并失败, 于是手动修改冲突对应区域,
然后
git commit –m “”
git pull origin master 重新拉取。
本地关联远程分支
git checkout -b develop
git push origin develop:develop
git push --set-upstream origin develop
本地仓库舍弃所有更改,变成与origin master 一致
git fetch --all
git reset --hard origin master
git更换远程地址并推送
git remote rm origin
git remote add origin $repo_url
git push --all origin
git配置代理
查看所有配置 git config -l
设置代理
- http协议
git config –global http.https://github.com.proxy https://127.0.0.1:1081
git config –global https.https://github.com.proxy https://127.0.0.1:1081
- socks5协议,1080端口修改成自己的本地代理端口
git config –global http.https://github.com.proxy socks5://127.0.0.1:1080
git config –global https.https://github.com.proxy socks5://127.0.0.1:1080
清除代理设置
git config –global –unset http.proxy
git config –global –unset https.proxy
常用命令
- 下载:git clone xxx地址
- 拉取:pull
- 添加:add
- 提交:commit
- 推送:git push origin dev
- 查看当前分支:git branch
- 切换分支:git checkout $branch_name
- 创建+切换分支:git checkout -b $branch_name
- 合并某分支到当前分支:git merge $branch_name
- 删除分支:git branch -D $branch_name
- 本地关联远程分支: git branch --set-upstream