git使用总结

1:git分支

    1)查看当前的远程库

      $ git remote -v

     

      2)push分支到服务器,如果你有个叫serverfix的分支需要和他人一起开发,可以运行git push (远程仓库名) (分支名)

        $ git push origin serverfix

         接下来,当你的协作者再次从服务器上获取数据时,他们将得到一个新的远程分支origin/serverfix:

     $ git fetch origin

     $ git chechout serverfix

2:新建标签

    a)创建一个含附注类型的标签非常简单,用 -a (译注:取 annotated 的首字母)指定标签名字即可:

      $ git tag -a v1.0 -m 'update to v1.0'

      而 -m 选项则指定了对应的标签说明,Git 会将此说明一同保存在标签对象中。如果没有给出该选项,Git 会启动文本编辑软件供你输入标签说明。

     b)可以使用 git show 命令查看相应标签的版本信息,并连同显示打标签时的提交对象。

       $git show v1.3

        

         我们可以看到在提交对象信息上面,列出了此标签的提交者和提交时间,以及相应的标签说明。

        c)轻量级标签

          轻量级标签实际上就是一个保存着对应提交对象的校验和信息的文件。要创建这样的标签,一个 -a-s 或 -m 选项都不用,直接给出标签名字即可

          $ git tag v1.4-lw

          $ git tag

          v1.2
          v1.3
          v1.4-lw

3:Git中的着色

  $ git config --global color.ui true设置好以后,当输出到终端时,Git 会为之加上颜色

 

4:恢复删除文件

  $ git checkout  47a08b4a7b38ab963dade11e024839fd396e7423 -- device/amlogic/PI3100_93/mali.ko

 

 

 

 

 

5:比较2个分支目录

$git diff T852..T852-SBK frameworks

6.

 

刚配置好的git仓库服务器,首次提交的时候会报如下错误:
remote: error: refusing to update checked out branch: refs/heads/master  
remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD. remote: error: 
 remote: error: You can set 'receive.denyCurrentBranch' configuration variable to 
 remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into 
 remote: error: its current branch; however, this is not recommended unless you 
 remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. 
remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To ... ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to

需要配置一下git的接收配置,执行如下命令即可正确提交:
# git config receive.denyCurrentBranch ignore

7:查看某次commit的详细记录,包括修改了哪些文件,该文件修改了哪些地方

# git show 7b0778531938e3fffb7a416e9f48c21c0785f586

 

8:恢复到某次的commit

git checkout  c039249d5085ff301a742a07230e1f3e1748acb8 -- device/amlogic/MID30801/version_id.mk

git add device/amlogic/MID30801/version_id.mk

# git commit -m 'AP6476恢复wl212'

9.从一个git仓库迁移到另外一个git仓库

git push --mirror git@gitcafe.com/username/newproject.git

或者使用下面命令迁移

git push --mirror http://192.168.1.28:/telechips/GT25DB-TCC8925.git

提交文件比较大时,缓存不够导致失败,提示“fatal: The remote end hung up unexpectedly”,需要把postBuffer设大一些,

如:git config --global http.postBuffer 1048576000

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值