当前位置:   article > 正文

推送本地项目到gitee_gitee本地推送

gitee本地推送

    giteegithub很类似,它是国内的一个开源代码托管与版本管理平台,它的很多命令与github非常类似。下面介绍,将本地项目推送到gitee。这里以threesmart工程为例,进行说明。

1、安装git

    官网地址: https://git-scm.com/downloads
    一路默认,直达安装完成。

2、配置ssh

2.1 生成ssh的公钥

    打开git bash,依次输入如下命令:

图(1) 使用管理员权限打开Git Bash

ssh-keygen -t rsa -C "youremail@youremail.com"  
## 先yes,然后一路回车,直到.ssh文件生成

## 查看.ssh公钥
cat ~/.ssh/id_rsa.pub
  • 1
  • 2
  • 3
  • 4
  • 5

2.2 在gitee里配置ssh公钥

    将C:\Users\xxx.ssh\id_rsa.pub里的内容,拷贝到gitee里的ssh公钥里。

图(2) gitee配置ssh公钥

3、设置用户名与邮箱

## 指定网段: gitee
ssh -T git@gitee.com

## 若遇到"'gitee.com ' can't be established", 请输入
yes

## 设置用户名与邮箱
git config --global user.name "yourname"
git config --global user.email "youremail@youremail.com"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

    name尽量与码云保持一致,email必须是注册码云时使用的邮箱。

4、创建新工程

4.1 在gitee里创建一个新工程

    在浏览器里,输入 gitee.com/projects/new,或者点击gitee左侧的+号即可,创建新工程。

图(3) 在gitee里创建新工程

4.2 设置过滤目录

    如果创建工程时,没有设置.gitignore,则可以新建一个.gitignore文件,来创建对应的过滤规则,比如,设置针对 nodejs的过滤目录,参考 github官网 .gitignore设置 即可。

## 新建.gitignore文件
touch .gitignore
  • 1
  • 2

//.gitignore的内容 (屏蔽nodejs相关的依赖包)

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118

5、拉取gitee项目到本地

git clone https://gitee.com/yourname/repository

## 比如
git clone https://gitee.com/docplus/threesmart.git
  • 1
  • 2
  • 3
  • 4

6、推送本地项目到gitee

## 进入到工程目录
cd threesmart

## 获取更新内容,并推送
git add .
git commit -m "initDemo"
git push origin master 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

参考文献

    [1] git入门配置
    [2] git配置ssh

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/694055
推荐阅读
相关标签
  

闽ICP备14008679号