git 流程以及bug自总

 

  1. 添加账号和邮箱
    1. vi .gitconfig
    2. :w
    3. 一直回车就行,第一个回车,会有git的路径

  1. 切换到git的路径下面
    1. cat id_rsa.pub
    2. 放到web 的git ssh=新建中文
  2. git的启用必须在 你建立的文件下面
  3. 创建分支
    1. 会有bug-Not a valid object name: 'master':
      1. 现在这个目录下随便建立个文本
      2. git commit -m hosts.txt
      3. 按照提示必须都填写
      4. git config --global user.email "you@example.com"

                            git config --global user.name "Your Name"

  1. 还有就是从仓库区提交到服务器的时候,可能没有连接会报错
    1. 本地分支和远程分支断开连接
    2. cd 本地分支里

                     1、git branch 

                           ——*master   只显示master

                       然后查看是否从上游拉了

                    2、git remote –v

                               ——若什么都没有,则和上游已断联系,拉不了代码也推不了代码 

                   3、加关联

                                  git remote add origin ssh://git@gitlab*********************************.git(地址)

                  -------------到这就可重新提交了------------------

                    若还不行:然后

                 4、git fetch origin

                         ——会显示下拉的branch情况

                    格式为From ssh://gitlab.********************************

                       *  [new branch]         XXXXX        ->origin/XXXXX

               再次检查远程仓库,显示对应的clone地址

             git remote –v

               ——origin  git://github.com/schacon/ticgit.git (fetch)

                origin  git://github.com/schacon/ticgit.git (push)

              然后再查分支

               git branch –a

                    ——* mater

                   remotes/origin/XXXXXX         **********

                     具体的切换分支可参考https://blog.youkuaiyun.com/tanningzhong/article/details/79724488

                       git 重命名仓库、修改远程仓库地址、修改仓库配置可参考:                               https://blog.youkuaiyun.com/u011884440/article/details/71246572

 

  1. 在提交:master报错信息如下

To https://github.com/CashFu/selenium3Fu.git

! [rejected] master -> master (non-fast-forward)

error: failed to push some refs to 'https://github.com/CashFu/selenium3Fu.git'

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方法:

  1. 看到提示里面,感觉是本地的代码不是最新的。

所以觉得应该是类似于svn中的,先update一下,再去commit,估计就可以了。

所以先去pull试试---输入:$ git pull

结果直接pull好像是不对的:

$ git pull remote: Enumerating objects: 6, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (6/6), done. From https://github.com/CashFu/selenium3Fu * [new branch] master -> origin/master There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> master

 

  1. 估计是指定对应的要pull的目标即可。

所以再去试试pull origin:

You asked to pull from the remote 'origin', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.

也还是不对。

  1. 再试试:git pull --rebase origin master
From https://github.com/CashFu/selenium3Fu * branch master -> FETCH_HEAD warning: unable to rmdir 'selenium3Fu': Directory not empty First, rewinding head to replay your work on top of it... Applying: hosts.txt Applying: lfittest_login—_lfj

可以看到,此时已经把github上最新的文件下载下来了

  1. 接着再去:

        git push origin master

---------------ok了------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值