初次创建远程仓库并推送本地项目到远程仓库

初次创建远程仓库并推送本地项目到远程仓库

步骤

管理员在远程创建仓库,有了远程仓库地址,但是没有代码。

在本地搭建项目

在项目中初始化仓库,并进行一次提交

在本地添加远程仓库

将本地代码推送到远程仓库

在项目中初始化仓库,并进行一次提交

1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization
$ git init
Initialized empty Git repository in C:/Users/1/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization/.git/

添加远程仓库

1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization (master)
$ git remote add origin git@192.168.1.254:devops/teach_organization.git
1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization (master)
$ git remote -v
origin  git@192.168.1.254:devops/teach_organization.git (fetch)
origin  git@192.168.1.254:devops/teach_organization.git (push)

将本地代码推送到远程仓库

1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization (master)
$ git push origin master
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 6 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (45/45), 54.74 KiB | 4.98 MiB/s, done.
Total 45 (delta 1), reused 0 (delta 0)
To 192.168.1.254:devops/teach_organization.git
 * [new branch]      master -> master

查看全部分支

1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization (master)
$ git branch -a
* master
  remotes/origin/master

bugs

如果本地git仓库一次提交都没有,则无法查看分支,也无法推送到远程仓库。

1@DESKTOP-3H9092J MINGW64 ~/Documents/WeChat Files/jiezzdota/FileStorage/File/2019-11/teach_organization (master)
$ git log
fatal: your current branch 'master' does not have any commits yet
posted @ 2019-11-05 08:25  没有理由不会呀  阅读(876)  评论(0编辑  收藏  举报