Git version control installation, configuration and use:

1. Download git

Download address: git official website
Download as shown in the figure

insert image description here

2. Unzip git

Download to the appropriate directory
insert image description here

3. Configure git environment environment variables

1. Computer –> System Advanced Settings –> Environment Variables –> System Environment Variables –> Path –> Edit
Note : It is the directory where the bin folder is located
insert image description here
2. Verify whether the configuration is successful: enter the command in the terminal to verify

Microsoft Windows [版本 10.0.19041.208]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\Administrator>git -v
git version 2.39.0.windows.1
C:\Users\Administrator>
C:\>bash
Administrator@wx MINGW64 /c
$ git -v
git version 2.39.0.windows.1
Administrator@wx MINGW64 /c
$ git --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>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local
branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
Administrator@wx MINGW64 /c
$

View git version information
git -help

C:\Users\Administrator>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>]

4. git common commands:

4.1. Clone the remote warehouse:

usegit clone remote warehouse addressCommand to clone the remote repository

git clone https://gitee.com/gz-yami/mall4j.git

The displayed result is:

Cloning into 'mall4j'...
remote: Enumerating objects: 6529, done.
remote: Counting objects: 100% (1242/1242), done.
remote: Compressing objects: 100% (1002/1002), done.
remote: Total 6529 (delta 504), reused 230 (delta 34), pack-reused 5287
Receiving objects: 100% (6529/6529), 14.45 MiB | 2.32 MiB/s, done.
Resolving deltas: 100% (3138/3138), done.

Indicates that the cloning is successful.

4.2. Use git to push files to the remote warehouse

1. Open the folder you want to push and use it in the terminalgit initcommand to initialize it as a git repository.
insert image description here
2. Use in terminalgit add *command to add files to the staging area (.git folder), usegit commitCommand to submit the code to the local warehouse
Note: Both the temporary storage area and the local warehouse are the contents of the git version library.

C:\Users\Administrator\Desktop\htmlcss>git add *
C:\Users\Administrator\Desktop\htmlcss>git commit -m init
[master (root-commit) 2a67031] init
1 file changed, 10 insertions(+)
create mode 100644 index.html
C:\Users\Administrator\Desktop\htmlcss>git status
On branch master
nothing to commit, working tree clean
C:\Users\Administrator\Desktop\htmlcss>

3. usegit pushPush the local git warehouse to the remote warehouse
Note: Before using git push to push, you must first configure git. In addition, the purpose of "-u" in git push -u origin "master" is to write git push directly for the next push of the local warehouse can

#配置git信息
git config --global user.name webrx
git config --global user.email [email protected]
#查看全局配置信息
C:\Users\Administrator>git config --global --list
user.name=webrx
user.email=[email protected]
safe.directory=D:/note
safe.directory=D:/soft/es
#添加文件并提交
git add *
git commit -m xxxx
#进入gitee.com ,建立好es.git空项目
#设置本地git版本库远端的仓库地址
git remote add origin https://gitee.com/webrx/es.git
#推项目,此时需要gitee账号密码相关信息
git push -u origin "master"
#以后操作
git add *
git commit -m xxx
git push
C:\Users\Administrator\Desktop\htmlcss>git add *
C:\Users\Administrator\Desktop\htmlcss>git commit -m "first commit"
[master (root-commit) f4e1dd4] first commit
1 file changed, 10 insertions(+)
create mode 100644 index.html
C:\Users\Administrator\Desktop\htmlcss>git remote add origin
https://gitee.com/webrx/htmlcss.git
C:\Users\Administrator\Desktop\htmlcss>git push -u origin "master"
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 383 bytes | 383.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/webrx/htmlcss.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
wechat:webrxwp - mobile:13014577033 - email:[email protected] - qq:7031633
11 / 35
git pull 拉取到本地
C:\Users\Administrator\Desktop\htmlcss>git push -u origin "master"
Everything up-to-date
branch 'master' set up to track 'origin/master'.
C:\Users\Administrator\Desktop\htmlcss>git add *
C:\Users\Administrator\Desktop\htmlcss>git commit -m index.css建立
[master d51bc03] index.css建立
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 css/index.css
C:\Users\Administrator\Desktop\htmlcss>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 323 bytes | 323.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/webrx/htmlcss.git
f4e1dd4..d51bc03 master -> master

Here is an example of a repository in gitee:

insert image description here

4.3 Pull remote warehouse code to local

usegit pullCommand to update the code in the remote warehouse to the local

git pull 

Note: If you want to transfer other people's cloned files to your own remote warehouse, you need to delete the cloned .git folder first, and then push it. Direct push will result in an error.

Guess you like

Origin blog.csdn.net/qq_46108215/article/details/128838909