github流程及解决办法

git机制

git机制

配置Git

  • 正如你在 起步 中看到的,可以用 git config 配置 Git。 首先要做的事情就是设置你的名字和邮件地址:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
  •   首先,快速回忆下:Git 使用一系列配置文件来保存你自定义的行为。 它首先会查找系统级的 /etc/gitconfig 文件,该文件含有系统里每位用户及他们所拥有的仓库的配置值。 如果你传递 --system 选项给 git config,它就会读写该文件。
  • 接下来 Git 会查找每个用户的 ~/.gitconfig 文件(或者 ~/.config/git/config 文件)。 你可以传递 --global 选项让 Git 读写该文件。
  • 最后 Git 会查找你正在操作的仓库所对应的 Git 目录下的配置文件(.git/config)。 这个文件中的值只对该仓库有效,它对应于向 git config 传递 --local 选项。
  • 以上三个层次中每层的配置(系统、全局、本地)都会覆盖掉上一层次的配置,所以 .git/config 中的值会覆盖掉 /etc/gitconfig 中所对应的值。

Command

查看配置

$ git config --list
  • 简写: git config -l
  • git config --list --global
    • location:
      • /etc/gitconfig(系统)–为全部用户配置
      • ~/.gitconfig(全局)–为单个用户配置
      • .git/config(本地)–为单个存储库配置

查看提交状态

    $ git status

添加到暂存区、本地仓库

#   . 代表提交当前目录下的所有unstage文件除去ignore文件
    $ git add .

    $ git commit -m "message" #简短提交信息
    $ git commit #在文件中编辑提交信息

    $ git commit -a -m "message" #合并add,commit操作
    或者
    $ git commit -am "message"

查看提交日志

    git log
    git log --oneline #简要版

推送远程仓库(false)

第一种:

#没有设置远程地址
$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

第二种:

#设置了远程地址,但是推送时没有加选项
$ git push
    
    fatal: The current branch main has no upstream branch.
    To push the current branch and set the remote as upstream, use

        git push --set-upstream mommy main

    To have this happen automatically for branches without a tracking
    upstream, see 'push.autoSetupRemote' in 'git help config'.

解决方案:#设置远程仓库地址

设置远程仓库地址

#随便起一个仓库链接别名mommy
    $ git remote add mommy https://github.com/hdb123456/Mommy.git
    $ git push mommy main
  • 查看远程仓库设置
       $ git romote 或git remote -v

代理问题

$ git pull mommy main
fatal: unable to access 'https://github.com/hdb123456/Mommy.git/': Failed to connect to github.com port 443 after 21117 ms: Couldn't connect to server

fatal: unable to access 'https://github.com/xxx/autowrite.git/':
Failed to connect to github.com port 443: Timed out

fatal: unable to access 'https://github.com/xxx/autowrite.git/': 
OpenSSL SSL_read: Connection was reset, errno 10054

解决方案:#取消代理

取消代理

#产生原因:git代理配置问题或网速问题
#取消http代理
$ git config --global --unset http.proxy
#取消https代理 
$ git config --global --unset https.proxy

仓库内容未同步

$ git push mommy main
info: please complete authentication in your browser...
To https://github.com/hdb123456/Mommy.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/hdb123456/Mommy.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方案:变基

commit未同步

$ git pull mommy main
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 862 bytes | 123.00 KiB/s, done.
From https://github.com/hdb123456/Mommy
 * branch            main       -> FETCH_HEAD
 * [new branch]      main       -> mommy/main
fatal: refusing to merge unrelated histories

解决方案:变基

变基

$ git pull --rebase mommy main

From https://github.com/hdb123456/Mommy
 * branch            main       -> FETCH_HEAD
Successfully rebased and updated refs/heads/main.

推送成功

$ git push mommy main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 299 bytes | 299.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/hdb123456/Mommy.git
   cee7e03..7007e68  main -> main
.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/hdb123456/Mommy.git
   cee7e03..7007e68  main -> main
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值