1.初始化仓库:git init
2.查看状态:git status
3.添加文件:git add 文件名(*指的是全部)
4.配置个人信息:
git config user.name 你的名字 git config user.email 你的邮箱
5.提交代码:git commit -m 版本信息
6.查看日志信息:git log --oneline
7.回退:git reset --hard HEAD/版本号
8.关联远程仓库:git remote add origin https://gitee.com/myasn/git_test.git
9.提交代码到远程仓库:git push -u origin "master"
10.获取远程仓库的代码:git pull origin master
11.分支操作:
#查看分支 git branch #创建分支 git branch b1 #切换到b1分支 git switch b1
#将b1分支合并到master git switch master git merge b1
如下是具体操作
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111
$ git init
Initialized empty Git repository in C:/Users/zj/Desktop/111/.git/
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
222.txt
nothing added to commit but untracked files present (use "git add" to track)
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git add *
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 222.txt
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 222.txt
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: 222.txt
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git add *
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 222.txt
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git commit -m 1.创建项目
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'zj@LAPTOP-2K3OPGHG.(none)')
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git config user.name 鸿儒菲克利斯
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git config user.email 2025916313@qq.com
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git commit -m 1.创建项目
[master (root-commit) 656dc17] 1.创建项目
1 file changed, 1 insertion(+)
create mode 100644 222.txt
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git log
commit 656dc1767151d5d19bba937a8d01c9ae88223ade (HEAD -> master)
Author: 鸿儒菲克利斯 <2025916313@qq.com>
Date: Mon Jun 20 14:34:35 2022 +0800
1.创建项目
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git log --oneline
656dc17 (HEAD -> master) 1.创建项目
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
nothing to commit, working tree clean
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
nothing to commit, working tree clean
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git add *
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git status
On branch master
nothing to commit, working tree clean
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git log --oneline
656dc17 (HEAD -> master) 1.创建项目
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ esc
bash: esc: command not found
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git commit
On branch master
nothing to commit, working tree clean
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ ^C
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (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: 222.txt
no changes added to commit (use "git add" and/or "git commit -a")
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)
$ git reset --hard HEAD
HEAD is now at 656dc17 1.创建项目
zj@LAPTOP-2K3OPGHG MINGW64 ~/Desktop/111 (master)