2 Star 3 Fork 7

JoyPoint / helloGIT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
helloGIT.txt 6.46 KB
一键复制 编辑 原始数据 按行查看 历史
JoyPoint 提交于 2019-09-25 10:39 . 更改为UTF-8,增加参考。
Gitee Git bash 操作简易说明
GIT
Git是一个分布式的版本控制系统,只是软件,需要你下载装到电脑上,实现git功能。
Github、Gitee基于git的项目托管平台。Github是国外的,连接速度因人而异;另外Github收费用户才能创建私有项目。
准备内容
1.注册码云(Gitee),创建一个项目,得到项目url:https://gitee.com/YourGiteeName/projectname。https://gitee.com/signup
2.下载git, 默认安装。https://git-scm.com/downloads
3.下载安装VSCode。https://code.visualstudio.com/
一、 生成ssh公钥
1. 打开Git Bash,按如下命令来生成 sshkey:
Administrator@Xinke MINGW64 ~
$ ssh-keygen -t rsa -C joypoint@qq.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:UoQbxa…… joypoint@qq.com
The key's randomart image is:
+---[RSA 3072]----+
| .o=.o.+o o .. |
| . =o o. |
| +. +*+.. . |
|. . o o |
|.+ + . o |
|o = . |
|.o . |
|.o . |
| o |
+----[SHA256]-----+
还可以用以下命令指定id_rsa的别名,用以配置多个SSH-Key:
$ ssh-keygen -t rsa -C 'xxxxx@company.com' -f ~/.ssh/gitee_id_rsa
2. 查看 public key:
Administrator@Xinke MINGW64 ~
$ cat ~/ .ssh/id_rsa.pub
cat: /c/Users/Administrator/: Is a directory
ssh-rsa AAAAB3NzaC1y…… joypoint@qq.com
打开码云SSH公钥管理页面: ?https://gitee.com/profile/sshkeys
填写标题,如:yourname's SSH key
复制公钥,如:ssh-rsa UoQbxa……
添加后,回到Git Bash中继续其他操作。
3. 用ssh命令测试是否配置成功:
Administrator@Xinke MINGW64 ~
$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (120.55.226.24)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9…….
Are you sure you want to continue connecting (yes/no/[fingerprint])? Yes
Warning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of known hosts.
Hi JoyPoint! You've successfully authenticated, but GITEE.COM does not provide shell access.
二、 Git操作-初始化Git
Administrator@Xinke MINGW64 ~
$ git config --global user.name JoyPoint
Administrator@Xinke MINGW64 ~
$ git config --global user.email JoyPoint@qq.com
三、 创建版本库
1. 首先,选择一个合适的地方,创建一个空目录YourProjName(名字任意):
Administrator@Xinke MINGW64 /
$ cd /c/ctk/
Administrator@Xinke MINGW64 /c/ctk
$ mkdir helloGIT
Administrator@Xinke MINGW64 /c/ctk
$ cd helloGIT
2. 第二步,通过git init命令把这个目录变成Git可以管理的仓库:
Administrator@Xinke MINGW64 /c/ctk/helloGIT
$ git init
Initialized empty Git repository in C:/CTK/helloGIT/.git/
四、 关联远程仓库
1. 把一个本地仓库与一个云端Gitee仓库关联:
项目地址形式为:https://gitee.com/YourGiteeName/YourProjName.git或者git@gitee.com:YourGiteeName/YourProjName.git
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git remote add origin https://gitee.com/JoyPoint/helloGIT.git
# 如果你发现地址关联有错,或想关联其他仓库,可以执行以下命令重新设置关联地址:
# $ git remote set-url origin https://gitee.com/JoyPoint/helloGIT.git
# 但一定要注意字母的大小写,以及文本双引号问题!!!
2. 查看关联细节:
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git remote -v
origin https://gitee.com/JoyPoint/helloGIT.git (fetch)
origin https://gitee.com/JoyPoint/helloGIT.git (push)
五、 同步(拉取)
同步,也可以称之为拉取,在Git中是非常频繁的操作,为了保证代码一致性,尽可能的在每次操作前进行一次同步操作,在工作目录下执行如下命令:
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git pull origin master
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From https://gitee.com/JoyPoint/helloGIT
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git status
On branch master
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: README.md
no changes added to commit (use "git add" and/or "git commit -a")
六、 提交
git作为支持分布式版本管理的工具,它管理的库(repository)分为本地库、远程库。如有本地库源码文件发生修改,需要将修改提交到远程库,这时需要暂存 (add)、提交(commit)、推送(push)三步:
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git add -A
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git commit -m "注意名称大小写和全角标点符号"
[master ee5acbb] 注意名称大小写和全角标点符号
1 file changed, 7 insertions(+), 5 deletions(-)
Administrator@Xinke MINGW64 /c/ctk/helloGIT (master)
$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 416 bytes | 416.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Powered By Gitee.com
To https://gitee.com/JoyPoint/helloGIT.git
babe7af..ee5acbb master -> master
七、 VSCode中使用git
1. 点击 文件 > 将文件夹添加到工作区 > E:/YourProjName/就完成了。
无需任何配置,VSCode自动获取.git配置实现代码管理: 发生变动的文件或代码会有颜色提示。
2. 同步远程仓库:
* 选择源控制栏(Source Control)中需要上传的文件,点击+号,暂存 (add);
* 在[ 消息 (按 Ctrl+Enter 提交) ]中输入注释, 提交(commit);
* 点击更多动作中的push图标,推送(push)。
————————————————————————————————
参考:https://blog.csdn.net/watfe/article/details/79761741
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/JoyPoint/helloGIT.git
git@gitee.com:JoyPoint/helloGIT.git
JoyPoint
helloGIT
helloGIT
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891