zoukankan      html  css  js  c++  java
  • 本地项目导入远程git仓库

    在你自己项目的根目录下执行如下命令
     1 //初始化git本地仓库
     2 git init
     3 
     4 //添加文件到本地git仓库
     5 git add .
     6 
     7 //提交文件到本地git仓库
     8 git commit -m"初始导入"
     9 
    10 //建立远程仓库链接
    11 git remote add origin xxx.git
    12 
    13 //推送到远程仓库
    14 git push origin master

    如果在执行git push origin master过程中报错如下:

    1 hint: Updates were rejected because the remote contains work that you do
    2 hint: not have locally. This is usually caused by another repository pushing
    3 hint: to the same ref. You may want to first integrate the remote changes
    4 hint: (e.g., 'git pull ...') before pushing again.
    5 hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    则表示远程仓库代码与本地仓库代码产生版本冲突,需要将远程仓库代码pull到本地

    1 //更新远程代码到本地仓库
    2 git pull origin master

    完成上面步骤之后,就可以将本地代码推送到远程仓库啦!

    1 //推送到远程仓库
    2 git push origin master

    至此本地项目导入远程仓库完成~

    附上git删除远程文件命令

    1 git rm -rf --cached target/*

    删除完成之后,commit、push

  • 相关阅读:
    Jenkins远程部署应用
    Centos7搭建Jenkins
    Centos7安装Docker
    Centos7安装Maven
    Centos7安装jdk
    由object元素引出的事件注册问题和层级显示问题
    ios中input输入无效
    手册
    CSS 清楚浮动总结
    JS 创建对象总结
  • 原文地址:https://www.cnblogs.com/thierry/p/5603554.html
Copyright © 2011-2022 走看看