最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】把本地已有仓库上传到Gitee码云的git仓库

Git crifan 72浏览 0评论
本地已有一个,从别处
git clone https://github.com/xxx/xxx.git
下载的代码,并且改动了一些。现在可以基本的跑起来了(虽然还有其他问题)
现在打算去上传到,自己的gitee中私有仓库
先去gitee新建仓库目录,和单个仓库
创建组织 – 码云 Gitee.com
https://gitee.com/organizations/new
xxx

xxxxxx

xxx,解析IEC 104协议数据
xxx: xxx,解析IEC 104协议数据
去设置
然后好像没有地方去设置为私有的。
估计默认私有。
现在去创建git代码仓库
xxx – 码云 Gitee.com
https://gitee.com/organizations/xxx/projects
xxx/xxx
简易的命令行入门教程:

Git 全局设置:


git config --global user.name "crifan"


git config --global user.email "xxx"


创建 git 仓库:


mkdir xxx


cd xxx


git init


touch README.md


git add README.md


git commit -m "first commit"


git remote add origin https://gitee.com/xxxxxx/xxx.git


git push -u origin master


已有仓库?


cd existing_git_repo


git remote add origin https://gitee.com/xxxxxx/xxx.git


git push -u origin master

去把本地已有代码,去上传到此仓库中。
不过此处特殊的是:
此处,最后打算,除了上传git仓库,还打算把其他文档等非代码,都上传上去。
所以,就不是普通的git仓库合并上传了。
而是删了之前.git目录,所有文件都上传
然后作为新项目,初始化git
➜  xxx git status
fatal: not a git repository (or any of the parent directories): .git
➜  xxx git init
Initialized empty Git repository in /Users/crifan/dev/dev_root/projects/xxx/.git/
➜  xxx git:(master) ✗ touch .gitignore
➜  xxx git:(master) ✗
去编辑
.gitignore
.DS_Store


*.class

再去添加所有文件:
➜  xxx git:(master) ✗ git status
On branch master


No commits yet


Untracked files:
  (use "git add <file>..." to include in what will be committed)


        .gitignore
        .vscode/
        data/
        doc/
        requirement/
        src/


nothing added to commit but untracked files present (use "git add" to track)
➜  xxx git:(master) ✗ git add .gitignore
➜  xxx git:(master) ✗ git status
On branch master


No commits yet


Changes to be committed:
  (use "git rm --cached <file>..." to unstage)


        new file:   .gitignore


Untracked files:
  (use "git add <file>..." to include in what will be committed)


        .vscode/
        data/
        doc/
        requirement/
        src/


➜  xxx git:(master) ✗ git add *
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/common/BalancedLinkCode.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/common/TypeIdentifier.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/CustomException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/IllegalFormatException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/LengthException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/UnknownLinkCodeException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/UnknownTransferReasonException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/exception/UnknownTypeIdentifierException.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/main/java/com/iec/analysis/protocol104/Analysis.java.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in src/xxx/src/test/java/com/iec/test/Analysis104Test.java.
The file will have its original line endings in your working directory
warning: adding embedded git repository: src/refer/python/iec104
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint:   git submodule add <url> src/refer/python/iec104
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint:   git rm --cached src/refer/python/iec104
hint:
hint: See "git help submodule" for more information.
意思是有个子git项目
是之前下载别的Python的参考代码。
所以也去删除.git目录
➜  xxx git:(master) ✗ rm -rf src/refer/python/iec104/.git/
➜  xxx git:(master) ✗ git status
On branch master


No commits yet


Changes to be committed:
  (use "git rm --cached <file>..." to unstage)


        new file:   .gitignore
        new file:   data/xxx_104_sample_data.txt
        new file:   doc/IEC 104 ASDU types/IEC 104 ASDU types - page 1.jpg
        new file:   doc/IEC 104 ASDU types/IEC 104 ASDU types - page 2.jpg
        new file:   doc/IEC 104 ASDU types/IEC 104 ASDU types - page 3.jpg
        new file:   doc/IEC 104 ASDU types/IEC 60870-5-104 asdu object reference - data types.xlsx
        new file:   doc/IEC60870-5-101_104_Slave_Technical_Reference.pdf
        new file:   doc/TR-IEC104.pdf
        new file:   doc/info_iec60870-5-104{ed2.0}en_d.pdf
...
src/xxx/src/test/java/com/iec/test/Analysis101Test.java
        new file:   src/xxx/src/test/java/com/iec/test/Analysis104Test.java
        new file:   src/refer/python/iec104


Untracked files:
  (use "git add <file>..." to include in what will be committed)


        .vscode/


➜  xxx git:(master) ✗ git add .vscode/
➜  xxx git:(master) ✗ git status
On branch master


No commits yet


Changes to be committed:
  (use "git rm --cached <file>..." to unstage)


        new file:   .gitignore
        new file:   .vscode/launch.json
        new file:   .vscode/settings.json
        new file:   data/xxx_104_sample_data.txt
...
        new file:   src/xxx/.classpath
        new file:   src/xxx/.gitignore
...src/xxx/src/test/java/com/iec/test/Analysis101Test.java
        new file:   src/xxx/src/test/java/com/iec/test/Analysis104Test.java
        new file:   src/refer/python/iec104
然后貌似就可以commit和push了?
➜  xxx git:(master) ✗ git commit -m "1. initial version of xxx removed errors and warnings and add other docs"
[master (root-commit) 2ecc088] 1. initial version of xxx removed errors and warnings and add other docs
61 files changed, 3725 insertions(+)
create mode 100644 .gitignore
create mode 100644 .vscode/launch.json
create mode 100644 .vscode/settings.json
create mode 100644 data/xxx_104_sample_data.txt
...
src/xxx/src/test/java/com/iec/test/Analysis101Test.java
create mode 100644 src/xxx/src/test/java/com/iec/test/Analysis104Test.java
create mode 160000 src/refer/python/iec104
➜  xxx git:(master) git remote add origin https://gitee.com/xxx/xxx.git
再去上传,结果报错:
【已解决】git代码上传gitee仓库报错:remote You do not have permission to push to the repository via HTTPS
需要输入账号和密码
输入了密码后,结果:
➜  xxx git:(master) git push -u origin master        
error: unable to read askpass response from 'git-gui--askpass'
Username for 'https://gitee.com':
重新输入正确的账号和密码
➜  xxx git:(master) git push -u origin master        
error: unable to read askpass response from 'git-gui--askpass'
Username for 'https://gitee.com': crifan
error: unable to read askpass response from 'git-gui--askpass'
Password for 'https://crifan@gitee.com':
再去输入密码
终于正常上传代码了:
➜  xxx git:(master) git push -u origin master        
error: unable to read askpass response from 'git-gui--askpass'
Username for 'https://gitee.com': crifan
error: unable to read askpass response from 'git-gui--askpass'
Password for 'https://crifan@gitee.com':
Enumerating objects: 91, done.
Counting objects: 100% (91/91), done.
Delta compression using up to 4 threads
Compressing objects: 100% (80/80), done.
Writing objects: 100% (91/91), 4.80 MiB | 6.54 MiB/s, done.
Total 91 (delta 11), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To https://gitee.com/xxx/xxx.git
* [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
去看看gitee中的代码
xxx: xxx,包含代码和其他文档。主要功能是IEC 104协议的解析
然后继续添加一个简单的README.md
至此即可。
另外,退出账号,确认公开无法访问,会403:
是对的。

转载请注明:在路上 » 【已解决】把本地已有仓库上传到Gitee码云的git仓库

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
16 queries in 0.089 seconds, using 9.37MB memory