下载指定分支
H:\codes\reactapps\reactdouban>git clone -b reactv1 https://gitee.com/xxxx/react-douban.git
Cloning into 'react-douban'...
remote: Enumerating objects: 55, done.
remote: Counting objects: 100% (55/55), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 55 (delta 14), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (55/55), done.
H:\codes\reactapps\reactdouban>
官网:
https://gitee.com/help/articles/4181#article-header0
生成/添加SSH公钥
SSH Key SSH 公钥
码云提供了基于SSH协议的Git服务,在使用SSH协议访问仓库仓库之前,需要先配置好账户/仓库的SSH公钥。
你可以按如下命令来生成 sshkey:
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
# Generating public/private rsa key pair...
注意:这里的 xxxxx@xxxxx.com 只是生成的 sshkey 的名称,并不约束或要求具体命名为某个邮箱。
现网的大部分教程均讲解的使用邮箱生成,其一开始的初衷仅仅是为了便于辨识所以使用了邮箱。
按照提示完成三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub 文件内容,获取到你的 public key
Microsoft Windows [版本 10.0.18363.1016]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\zch>ssh-keygen -t rsa -C "xxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\zch/.ssh/id_rsa):
Created directory 'C:\Users\zch/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\zch/.ssh/id_rsa.
Your public key has been saved in C:\Users\zch/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HamgRVL+0hxD0W59k8uFjnsioLVqhEpmtw4aCEuHBgk xxx@qq.com
The key's randomart image is:
+---[RSA 2048]----+
|E ..o oo |
|.. + . .. |
|o + o.o. o |
| o... o . . o . |
+----[SHA256]-----+
C:\Users\zch>
=== 验证是否添加成功
C:\Users\zch>ssh -T git@gitee.com
The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
Hi [36;01mZC[0m! You've [32msuccessfully[0m authenticated, but GITEE.COM does not provide shell access.
C:\Users\zch>
Microsoft Windows [版本 10.0.18363.1016]
(c) 2019 Microsoft Corporation。保留所有权利。
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: .eslintignore
new file: .eslintrc.js
new file: vue.config.js
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
a.js
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git add.
git: 'add.' is not a git command. See 'git --help'.
The most similar command is
add
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git add .
warning: LF will be replaced by CRLF in package-lock.json.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in package.json.
The file will have its original line endings in your working directory
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git commit -m "add files"
[master ff2e123] add files
6 files changed, 555 insertions(+), 4 deletions(-)
create mode 100644 .eslintignore
create mode 100644 .eslintrc.js
create mode 100644 a.js
create mode 100644 vue.config.js
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git status
On branch master
nothing to commit, working tree clean
主要是使用下面两条命令,把本地项目提交到码云上,下面的两条命令是在码云上创建仓库之后生成的,创建仓库成功后的效果图如上,
git remote add origin https://gitee.com/xxx/reactdemo.git
git push -u origin master
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git remote add origin https://gitee.com/xxx/reactdemo.git
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git push -u origin master
Enumerating objects: 138, done.
Counting objects: 100% (138/138), done.
Delta compression using up to 6 threads
Compressing objects: 100% (127/127), done.
Writing objects: 100% (138/138), 161.64 KiB | 3.37 MiB/s, done.
Total 138 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), done.
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/zchaixy/demo.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>
创建子分支
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git checkout -b login
Switched to a new branch 'login'
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git brench
git: 'brench' is not a git command. See 'git --help'.
The most similar command is
branch
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>git branch
* login
master
E:\codes\myvuexm\vue_webpack\vuexm3\vuepro3>
--------------
简易的命令行入门教程:
Git 全局设置:
git config --global user.name "zch"
git config --global user.email "437750912@qq.com"
创建 git 仓库:
mkdir talent-elasticsearch
cd talent-elasticsearch
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/zchaixy/talent-elasticsearch.git
git push -u origin master
已有仓库?
cd existing_git_repo
git remote add origin https://gitee.com/zchaixy/talent-elasticsearch.git
git push -u origin master
E:\codes\springs\talentelasticsearch>git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
notes/
nothing added to commit but untracked files present (use "git add" to track)
E:\codes\springs\talentelasticsearch>git add .
E:\codes\springs\talentelasticsearch>git commit -m "second commit"
[master 0ad6a9e] second commit
3 files changed, 165 insertions(+)
create mode 100644 notes/talent - Copy.sql
create mode 100644 notes/talent.conf
create mode 100644 notes/talent.sql
E:\codes\springs\talentelasticsearch>git push
To https://gitee.com/zchaixy/talent-elasticsearch.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/zchaixy/talent-elasticsearch.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
E:\codes\springs\talentelasticsearch>git push -u origin master
To https://gitee.com/zchaixy/talent-elasticsearch.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/zchaixy/talent-elasticsearch.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
E:\codes\springs\talentelasticsearch>git pull
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 230 bytes | 3.00 KiB/s, done.
From https://gitee.com/zchaixy/talent-elasticsearch
0ee2ee7..8ba3c70 master -> origin/master
Removing target/test-classes/com/kzkd/essearch/TestControllerCase.class
.....
拉取后再提交
E:\codes\springs\talentelasticsearch>git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 6 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 626 bytes | 626.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/zchaixy/talent-elasticsearch.git
8ba3c70..a5087d0 master -> master
E:\codes\springs\talentelasticsearch>