美文网首页生产力工具
git push 到远程分支

git push 到远程分支

作者: 尉昌达 | 来源:发表于2017-03-01 09:49 被阅读13479次

    在项目中

    git init
    git add .
    git commit -m "  "
     
    

    连接远程主机

    git remote add [远程主机名] [url]
    

    一种方式是:

     git push <远程主机名> <本地分支名>:<远程分支名>
    

    另一种是:在本地新建分支并切换到该分支

    git checkout -b [本地分支名]
    

    如果直接

    git push [本地分支名]
    

    出现

    fatal: The current branch zheer has no upstream branch.
    To push the current branch and set the remote as upstream, use
    
        git push --set-upstream zheer zheer
    

    然后

    git push --set-upstream  [远程主机名] [远程分支名]
    

    强制推送本地master到远程master

    git push -f master master
    

    一些git流程

    git clone git_url
    
    git branch 
    
    git branch branch_name
    
    git checkout branch_name
    
    
    .......
    
    git status 
    
    git diff
    
    git add .
    
    ->>>>>>
    
    git commit -m "description"(提交到本地库)
    
    git status
    
    git checkout master
    
    git pull origin master
    
    git merge branch_name(把自己分支上改动的代码,合并到主分支上)
    
    git push origin master (提交到远程库)
    
    git log (查看历史提交记录)
    
    
    

    直接pull主机的分支,覆盖本地

    $ git fetch <远程主机名> <分支名>
    git reset --hard<远程主机名>/<分支名>
    

    相关文章

      网友评论

        本文标题:git push 到远程分支

        本文链接:https://www.haomeiwen.com/subject/bphqgttx.html