IDEA + github 初次使用踩坑

chengfeng2023 / 2023-08-25 / 原文

  大学毕业至今没怎么用过git, 作为计算机专业的学生多少汗颜, 工作用的gitblit, 在IDEA上也只会pull commit push三个按键. 

  由于最近上班摸鱼时间太多, 打算多用用git, 也多在github活跃一些. 

  建立本地仓库, commit然后push自然不多提了, 网上的攻略很多. 简单记录几个坑.

  坑:

  1.在github上建立了仓库时顺手建了README, 推送的时候容易有问题.

    解决: 删了, 等一切正常了再建

 

  2. push的时候很慢, 几百KB/s, 有点忍不了遂打算开梯子. cancel了以后开梯子push, 直接报错 Failed to connect to github.com port 443 after 21070 ms: Couldn't connect to server, 传都不让传了.

    解决: set http_proxy=127.0.0.1:XXX

       set https_proxy=127.0.0.1:XXX

      XXX是梯子的端口, 我这是7890, 填入7890即可

 

   3. 本地branch是master, github是main. 又捉急了.

    解决: 参考链接 

      主要还是关注local branch和 remote branch, 只有local没有remote, fetch一下即可

 

  4. 第一次push的时候里面有个打包的jar, 超出了github最大上传限值100MB

    解决: github提示了该如何上传大文件, 可以去指定链接参考. 我仅是把它删除了, 代码如下, 填入自己的文件名即可. 

       参考链接

git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk

git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well

git push
# Push our rewritten, smaller commit