git操作

有的时候需要网上找好多文章才能搞对,所以自己记录对应的操作

一、第一次上传

初始化  
git init
检测文件状态(有没有被追踪Untracked)
git status
追踪全部本地文件到暂存区
git add . 
增加描述到git了
git commit -m '描述'

如果你没设置过 需先设置
git config --global user.name yourName
git config --global user.email yourEmail

绑定远程git地址
git remote add origin {远程仓库地址}
对应的移除命令:git remote remove origin 
git remote -v
# Verifies the new remote URL

 

以下是有master分支需要拉取的情形,如果在服务器仓库未初始化分支,跳过拉取直接上传:

如果从未拉取过,使用git push -u origin master命令会出现错误如下:
    $ git push -u origin master
    To http://*:*/*.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'http://*:*/*.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.
需要拉取,使用git pull 出现如下错误:
    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
使用git pull origin master出现如下错误:
From http://*/test
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

需使用如下命令合并:        
git pull origin master --allow-unrelated-histories
推送上去:
git push origin master:master

有很多按照网上说的都不好使,第一次上传我这是好用的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值