将本地项目提交到github/gitlab中[改]

文章是copy来的.但当时一直没成功.第5步之后有我补充内容.能帮到您是我的荣幸
准备工作:

在github/gitlab中新建项目audit

1.在本地目录zhunions目录下初始化本地仓库

git init

2.建立.gitignore README.md文件

3.本地提交

git add . 
git commit -m "first commit"

4.添加远程关联

git remote add origin git@172.16.10.9:namespace/zhunions.git

5.本地分支与远程分支关联,并推送到远程仓库

git push --set-upstream origin master

以上5步可以完成本地仓库和分支与远程仓库和分支的关联.

如果出现 git pull 出现

warning: no common commits
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From https://gitee.com/qbz2004/enter_manager
 * [new branch]      master     -> origin/master
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 branch --set-upstream-to=origin/mastermaster

或者出现

fatal: refusing to merge unrelated histories

执行

git pull origin branchname --allow-unrelated-histories

branchname 改成 master
本地 master 与 远程master已经建立好关联
下一步切换到dev上

$ git branch -a
  * master
  remotes/origin/dev
  remotes/origin/master

切换分支

git branch --set-upstream-to=origin/dev dev

未完待续

执行所有操作后,有如下结果:

a.产生本地分支master

b.与本地仓库关联的远程仓库origin

c.与本地分支关联的远程分支master

d.本地代码全部提交到了远程仓库,其他人可以共享了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值