Git一些麻烦使用示例
设置账号和用户名
# 查看git config设置
git config -l
git config --global user.name "xxx"
git config --global user.email "xxx"
Github / Gitee添加密钥
# 生成密钥
ssh-keygen -t rsa
# 查看公钥
cat ~/.ssh/id_rsa.pub
将公钥添加到Github / Gitee
添加多个远程仓库
1. 将主库git到本地
# 添加gitee库,使用ssh链接以防git push总是需要密码
git remote add <远程库名> <ssh>
# 查看远程仓库地址
git remote -v
2. push
git push && git push <远程库名>
3. 副库出现冲突
hint: Updates were rej ected because the tip of your current branch is behind
4. 强行推送到副库
# git push -u <远程库名> <版本名> -f
git push -u gitee master -f
加速Git
1. 安装nslookup
sudo yum install bind-utils
2. 查找DNS
nslookup github.com
nslookup github.global.ssl.fastly.net
3. 修改hosts
4. 刷新缓存
-
ubuntu
sudo /etc/init.d/networking restart -
mac
sudo dscacheutil -flushcache -
windows
ipconfig /flushdns
拉取项目,修改代码后创建新版本
1. 拉取已经fork远程项目
git clone 远程项目
2. 修改项目文件
3. 创建版本分支
git branch test
4. 切换到版本分支
git checkout test
5. 提交文件
git commit -m "test"
6. 同步到远程分支版本
git push origin test
posted on 2020-08-26 11:37 ctrlplayer 阅读(174) 评论(0) 收藏 举报
浙公网安备 33010602011771号