下载
解压
配置
环境变量
验证git配置是否正确并查看git版本信息
C:\Users\26330>bash
26330@victory MINGW64 ~
$ git -v
git version 2.39.1.windows.1
26330@victory MINGW64 ~
$ git -help
unknown option: -help
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--super-prefix=<path>] [--config-env=<name>=<envvar>]
<command> [<args>]
git clone 克隆项目
D:\BYJY>git clone https://gitee.com/dalaoer/miao-database.git
Cloning into 'miao-database'...
remote: Enumerating objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Receiving objects: 100% (39/39), 2.16 MiB | 766.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
D:\BYJY>git clone https://gitee.com/webrx/htmlcss.git
Cloning into 'htmlcss'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (1/1), done.
git init 初始化
D:\HelloWorld>git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in D:/HelloWorld/.git/
git add 增加文件、git commit提交、git remote 设置远端仓库地址、git push 推送远端
#配置git信息
D:\HelloWorld>git config --global user.name SSH-VICTORY
D:\HelloWorld>git config --global user.email 2633039017@qq.com
#查看全局配置信息
D:\HelloWorld>git config --global --list
user.name=SSH-VICTORY
user.email=2633039017@qq.com
#添加文件
D:\HelloWorld>git add *
#提交文件
D:\HelloWorld>git commit -m init
[master (root-commit) 716da8c] init
2 files changed, 5 insertions(+)
create mode 100644 HelloWorld.class
create mode 100644 HelloWorld.java
#设置本地git版本库远端的仓库地址
D:\HelloWorld>git remote add origin https://gitee.com/ssh666666/test.git
#推送项目,此时需要分别输入gitee的账户和密码
D:\HelloWorld>git push -u origin "master"
Username for 'https://gitee.com': 2633039017@qq.com
Password for 'https://2633039017@qq.com@gitee.com':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 630 bytes | 630.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/ssh666666/test.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
#往后只需如此
git add *
git commit -m xxx
git push
#例如
D:\HelloWorld>git add *
D:\HelloWorld>git commit -m 猜数字
[master 35a0a6d] 猜数字
2 files changed, 73 insertions(+)
create mode 100644 GuessNumber.class
create mode 100644 GuessNumber.java
D:\HelloWorld>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 2.28 KiB | 2.28 MiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/ssh666666/test.git
716da8c..35a0a6d master -> master