本地服务器上传代码到gitee仓库

  • Post author:
  • Post category:其他



把gitlab仓库里的node-day01项目传到本地服务器,再把本地服务器里的node-day01项目传到Gitee代码仓库



1 登录Gitlab,复制代码仓库地址

在这里插入图片描述



2 拷贝一刚复制的Git 仓库到本地

root@ubuntu:~# git clone http://192.168.10.9/node-demo/node-day01.git

Cloning into ‘node-day01’…



3 本地服务器上传代码到gitee仓库


  • 登录Gitee


    在这里插入图片描述

  • 新建仓库

在这里插入图片描述


  • clone克隆仓库到本地服务器


    进入linux

    如果没有安装git,可以执行以下命令安装git
yum install git

  • 配置git全局环境
git config --global user.name "abc344327477"
git config --global user.email "abc190425@*"

  • 修改commit默认打开的文本编辑工具
git config --global core.editor "vim"

  • 开始克隆:
root@ubuntu:~# git clone https://gitee.com/abc344327477/node-day02.git
Cloning into 'node-day01'...
Username for 'https://gitee.com': abc344327477
Password for 'https://abc344327477@gitee.com': 
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), pack-reused 0
Unpacking objects: 100% (4/4), 1.76 KiB | 1.76 MiB/s, done.

  • 查看克隆下来的文件夹
root@ubuntu:~# ls
213          aws-iam-authenticator  gitlab-damo      node-day02     wg0.conf
asd          bin                    go               node.yaml
awk-insgres  dist.zip               kkk              prometheus-dev
aws          doc.ttx                kuboard-v3.yaml  snap

  • 进入node-day01,并拷贝node-day01里的所有文件到node-day02中
cd /root/node-day01
cp -r /root/node-day01/* /root/node-day02

  • 查看文件是否拷贝成功
root@ubuntu:~/node-day02# ll
total 1316
drwxr-xr-x  8 root root   4096 Mar 15 16:18 ./
drwx------ 21 root root   4096 Mar 15 15:27 ../
-rw-r--r--  1 root root     89 Mar 15 16:18 babel.config.js
drwxr-xr-x  3 root root   4096 Mar 15 16:18 blog/
-rw-r--r--  1 root root     92 Mar 15 16:18 Dockerfile
-rw-r--r--  1 root root    212 Mar 15 16:18 Dockerfile-123
drwxr-xr-x  4 root root   4096 Mar 15 16:18 docs/
-rw-r--r--  1 root root   3252 Mar 15 16:18 docusaurus.config.js
drwxr-xr-x  8 root root   4096 Mar 15 15:56 .git/
-rw-r--r--  1 root root    333 Mar 15 16:18 my.conf
drwxr-xr-x  7 root root   4096 Mar 15 16:17 node-day01/
-rw-r--r--  1 root root    614 Mar 15 16:18 node.yaml
-rw-r--r--  1 root root    924 Mar 15 16:18 package.json
-rw-r--r--  1 root root 911675 Mar 15 16:18 package-lock.json
-rw-r--r--  1 root root    821 Mar 15 15:21 README.en.md
-rw-r--r--  1 root root    770 Mar 15 16:18 README.md
-rw-r--r--  1 root root    727 Mar 15 16:18 sidebars.js
drwxr-xr-x  5 root root   4096 Mar 15 16:18 src/
drwxr-xr-x  3 root root   4096 Mar 15 16:18 static/
-rw-r--r--  1 root root 359001 Mar 15 16:18 yarn.lock

其中README.md是文档说明,采用Markdown格式编写。


  • 添加源文件到本地仓库:
root@ubuntu:~/node-day02# git add *
root@ubuntu:~/node-day02# git status 
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   blog/2019-05-28-first-blog-post.md
	new file:   blog/2019-05-29-long-blog-post.md
	new file:   blog/2021-08-01-mdx-blog-post.mdx
	new file:   blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg
	new file:   blog/2021-08-26-welcome/index.md
	new file:   blog/authors.yml
	new file:   docs/Ga-staking/_category_.json
	new file:   docs/Ga-staking/read.md
	new file:   docs/Phoneix-pubk/_category_.json
	new file:   docs/Phoneix-pubk/read.md
	new file:   docs/intro.md
	new file:   src/components/HomepageFeatures/index.js
	new file:   src/components/HomepageFeatures/styles.module.css
	new file:   src/css/custom.css
	new file:   src/pages/index.js
	new file:   src/pages/index.module.css
	new file:   src/pages/markdown-page.md
	new file:   static/.nojekyll
	new file:   static/img/docusaurus.png
	new file:   static/img/favicon.ico
	new file:   static/img/logo.svg
	new file:   static/img/tutorial/docsVersionDropdown.png
	new file:   static/img/tutorial/localeDropdown.png
	new file:   static/img/undraw_docusaurus_mountain.svg
	new file:   static/img/undraw_docusaurus_react.svg
	new file:   static/img/undraw_docusaurus_tree.svg

  • 执行commit -m 加文件描述
root@ubuntu:~/node-day02# git commit -m 'd'   # 后面要加上文件的描述,根据实际情况写

[master 162c72e] d
 26 files changed, 1491 insertions(+)
 create mode 100644 blog/2019-05-28-first-blog-post.md
 create mode 100644 blog/2019-05-29-long-blog-post.md
 create mode 100644 blog/2021-08-01-mdx-blog-post.mdx
 create mode 100644 blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg
 create mode 100644 blog/2021-08-26-welcome/index.md
 create mode 100644 blog/authors.yml
 create mode 100644 docs/Ga-staking/_category_.json
 create mode 100644 docs/Ga-staking/read.md
 create mode 100644 docs/Phoneix-pubk/_category_.json
 create mode 100644 docs/Phoneix-pubk/read.md
 create mode 100644 docs/intro.md
 create mode 100644 src/components/HomepageFeatures/index.js
 create mode 100644 src/components/HomepageFeatures/styles.module.css
 create mode 100644 src/css/custom.css
 create mode 100644 src/pages/index.js
 create mode 100644 src/pages/index.module.css
 create mode 100644 src/pages/markdown-page.md
 create mode 100644 static/.nojekyll
 create mode 100644 static/img/docusaurus.png
 create mode 100644 static/img/favicon.ico
 create mode 100644 static/img/logo.svg
 create mode 100644 static/img/tutorial/docsVersionDropdown.png
 create mode 100644 static/img/tutorial/localeDropdown.png
 create mode 100644 static/img/undraw_docusaurus_mountain.svg
 create mode 100644 static/img/undraw_docusaurus_react.svg
 create mode 100644 static/img/undraw_docusaurus_tree.svg

  • 上传到服务器:
root@ubuntu:~/node-day02# git push 
Username for 'https://gitee.com': abc344327477      #输入gitee账号
Password for 'https://abc344327477@gitee.com':      #输入giteem密码
Enumerating objects: 42, done.
Counting objects: 100% (42/42), done.
Delta compression using up to 8 threads
Compressing objects: 100% (36/36), done.
Writing objects: 100% (41/41), 190.75 KiB | 15.90 MiB/s, done.
Total 41 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.3]
To https://gitee.com/abc344327477/node-day02.git
   162c72e..d7ba02a  master -> master

  • 回到giett ,node-day02库中查看上传成功的代码

在这里插入图片描述

这样我们就成功的将本地代码上传到gitee代码仓库了。


git clone 项目地址 拉项目

git pull 拉代码

git push 提交到仓库

git init 指令初始化一个git仓库

git add .添加文件

git commit -m “注释”提交至仓库。

git remote add origin https://git.oschina.net/你的用户名/项目名.

git,git push origin master即可完成推送

git checkout master 切换到master分支



报错:

提交代码遇到『Everything up-to-date』

出现这个问题的原因是git提交改动到缓存,要push的时候不会将本地所有的分支都push掉,所以出现这个问题。我们应该告诉git提交哪个分支。

1 使用git branch查看有什么分支

root@ubuntu:~/node-day02# git branch
  a
*master

2 输入 git checkout master切换到master上

root@ubuntu:~/node-day02# git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.

3 这样就切换完了,可以 $ git branch 确认下。然后你要将你的改动提交到新的分支上,前面的*代表的是当前你所在的工作分支

root@ubuntu:~/node-day02# git branch 
  a
*master
root@ubuntu:~/node-day02# 

4 提交

git add .
git commit -m 'cccccc'

5 此时可以 git status 检查下提交情况。如果提交成功,我们接下来就要回主分支了,代码和之前一样。

git checkout master

6 执行git push ,就能在gitee看到提交的的代码



版权声明:本文为clover661原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。