常用命令
1.git config命令查看用户名,邮箱
git config user.name
git config user.email
2.git config命令 修改自己的用户名和邮箱
//仅对当前仓库有效
git config --local user.email "你的名字"
git config --local user.email "你的邮箱"//对当前用户的所有仓库有效
git config --global user.email "你的名字"
git config --global user.email "你的邮箱"
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo
#初始化本地目录
$ git init
Initialized empty Git repository in D:/file/gitspace/git-demo/.git/
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll
total 0
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll -a
total 4
drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 ./
drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 ../
drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 .git/
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll
total 0
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ vi first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
first-demo.txt
nothing added to commit but untracked files present (use "git add" to track)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
#添加暂存区
$ git add first-demo.txt
warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
#删除暂存区
$ git rm --cached first-demo.txt
rm 'first-demo.txt'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
first-demo.txt
nothing added to commit but untracked files present (use "git add" to track)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll
total 1
-rw-r--r-- 1 BOCO 197121 81 Mar 21 17:41 first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git add first-demo.txt
warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
#提交本地库
$ git commit -m "first commit" first-demo.txt
warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
[master (root-commit) e2d4217] first commit
1 file changed, 9 insertions(+)
create mode 100644 first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git log
commit e2d4217ecfdb63e0c0a4b6de6e90bb9232b50e30 (HEAD -> master)
Author: smile <jiulongyueer@outlook.com>
Date: Tue Mar 21 17:42:32 2023 +0800
first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git relog
git: 'relog' is not a git command. See 'git --help'.
The most similar command is
reflog
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reflog
e2d4217 (HEAD -> master) HEAD@{0}: commit (initial): first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ vi first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
#修改文件内容12345678
$ cat first-demo.txt
hello git
hello git
12345678
hello git
hello git
hello git
hello git
hello git
hello git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (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: first-demo.txt
no changes added to commit (use "git add" and/or "git commit -a")
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git add first-demo.txt
warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git commit -m "second commit" first-demo.txt
warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
[master 8a4ea4f] second commit
1 file changed, 1 insertion(+), 1 deletion(-)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reflog
8a4ea4f (HEAD -> master) HEAD@{0}: commit: second commit
e2d4217 HEAD@{1}: commit (initial): first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
版本穿梭
$ git reflog
8a4ea4f (HEAD -> master) HEAD@{0}: commit: second commit
e2d4217 HEAD@{1}: commit (initial): first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ^C
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git log
commit 8a4ea4fa40ce2adf9553998ffcccd8af4bedb14a (HEAD -> master)
Author: smile <jiulongyueer@outlook.com>
Date: Wed Mar 22 11:28:28 2023 +0800
second commit
commit e2d4217ecfdb63e0c0a4b6de6e90bb9232b50e30
Author: smile <jiulongyueer@outlook.com>
Date: Tue Mar 21 17:42:32 2023 +0800
first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reset --hard 8a4ea4f
HEAD is now at 8a4ea4f second commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reflog
8a4ea4f (HEAD -> master) HEAD@{0}: reset: moving to 8a4ea4f
8a4ea4f (HEAD -> master) HEAD@{1}: commit: second commit
e2d4217 HEAD@{2}: commit (initial): first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
12345678
hello git
hello git
hello git
hello git
hello git
hello git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reset --hard e2d4217
HEAD is now at e2d4217 first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git reflog
e2d4217 (HEAD -> master) HEAD@{0}: reset: moving to e2d4217
8a4ea4f HEAD@{1}: reset: moving to 8a4ea4f
8a4ea4f HEAD@{2}: commit: second commit
e2d4217 (HEAD -> master) HEAD@{3}: commit (initial): first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$
Git分支
在版本控制过程中,同时推进多个任务,为每个任务,我们就可以创建每个任务的单独分支。使用分支意味着程序员可以把自己的工作从开发主线上分离开来,开发自己分支的时候,不会影响主线分支的运行。对于初学者而言,分支可以简单理解为副本,一个分支就是一个单独的副本。(分支底层其实也是指针的引用)
分支的操作:
命令名称 | 作用 |
git branch 分支名 | 创建分支 |
git branch -v | 查看分支 |
git checkout 分支名 | 切换分支 |
git merge 分支名 | 把指定的分支合并到当前分支上 |
新建一个分支,然后切换分支hot-fix修改文件,修改后回到master分支查看。
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ^C
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git branch hot-fix
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git branch -v
hot-fix e2d4217 first commit
* master e2d4217 first commit
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ vim first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
fix finish
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git status
On branch hot-fix
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: first-demo.txt
no changes added to commit (use "git add" and/or "git commit -a")
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git add first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git commit -m "hot-fix first commit" first-demo.txt
[hot-fix 0876f30] hot-fix first commit
1 file changed, 1 insertion(+), 1 deletion(-)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git checkout master
Switched to branch 'master'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
合并分支
$ git merge hot-fix
Updating e2d4217..0876f30
Fast-forward
first-demo.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
fix finish
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$
合并冲突:当两个版本之间合并时发生冲突,需要手动合并
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
fix finish master
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git add first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git commit -m "master first-test commit" first-demo.txt
[master 09fe8f2] master first-test commit
1 file changed, 1 insertion(+), 1 deletion(-)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
fix finish
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ vi first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git hot-fix
fix finish
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git add first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git commit -m "hot-fix second commit" first-demo.txt
[hot-fix b55f4de] hot-fix second commit
1 file changed, 1 insertion(+), 1 deletion(-)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git checkout master
Switched to branch 'master'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git merge hot-fix
Auto-merging first-demo.txt
CONFLICT (content): Merge conflict in first-demo.txt
Automatic merge failed; fix conflicts and then commit the result.
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
<<<<<<< HEAD
hello git
fix finish master
=======
hello git hot-fix
fix finish
>>>>>>> hot-fix
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
$ vi first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
$ git merge hot-fix
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
$ git add first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
#这里手动合并后不能跟文件名
$ git commit -m "test merge" first-demo.txt
fatal: cannot do a partial commit during a merge.
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
$ git commit -m "test merge"
[master 04c1998] test merge
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git hot-fix
fix finish master
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git hot-fix
fix finish
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$
创建远程仓库:
选择public,私有的有人数限制,多人建议自己搭建gitlab
创建成功
然后创建远程库别名
基本语法:
git remote-v 查看当前所有远程地址别名
git remote add 别名 远程地址
$ git remote -v
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git remote add git-demo https://github.com/SbossS/git-demo.git
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git remote -v
git-demo https://github.com/SbossS/git-demo.git (fetch)
git-demo https://github.com/SbossS/git-demo.git (push)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
$ git checkout master
Switched to branch 'master'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll
total 1
-rw-r--r-- 1 BOCO 197121 128 Mar 23 10:29 first-demo.txt
#想远程仓库推送代码
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git push git-demo master
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 4 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (15/15), 1.14 KiB | 25.00 KiB/s, done.
Total 15 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), done.
To https://github.com/SbossS/git-demo.git
* [new branch] master -> master
#从远程仓库拉取代码
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git pull git-demo master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 661 bytes | 1024 bytes/s, done.
From https://github.com/SbossS/git-demo
* branch master -> FETCH_HEAD
04c1998..be81036 master -> git-demo/master
Updating 04c1998..be81036
Fast-forward
first-demo.txt | 1 +
1 file changed, 1 insertion(+)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ ll
total 1
-rw-r--r-- 1 BOCO 197121 141 Mar 23 10:39 first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git hot-fix
fix finish master
git editing
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$
团队内合作
克隆远程仓库到本地
git clone 地址
两个账号 jiulong2023 SbossS 切换账号时需要删除凭据管理器里原来的账号
流程:新建 jiulong2023账号的目录,进入bash,然后clone文件,修改文件,add commit,退出SbossS 账号,用 jiulong2023账号登录git,SbossS 邀请 jiulong2023加入collaborators,然后jiulong2023提交远程仓库,然后删除凭据管理器里jiulong2023,切换到SbossS本地路径下pull代码。
bossS 邀请 jiulong2023加入collaborators
jiulong2023:
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong
$ git clone https://github.com/SbossS/git-demo.git
Cloning into 'git-demo'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 18 (delta 6), reused 14 (delta 5), pack-reused 0
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (6/6), done.
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong
$ cd git-demo/
'
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$ ll
total 1
-rw-r--r-- 1 BOCO 197121 141 Mar 23 11:21 first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$ vi first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$ git remote -v
origin https://github.com/SbossS/git-demo.git (fetch)
origin https://github.com/SbossS/git-demo.git (push)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$ git add first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
$ git commit -m "jiulong2023 commit" first-demo.txt
[master 555ee70] jiulong2023 commit
1 file changed, 1 insertion(+)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (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% (2/2), done.
Writing objects: 100% (3/3), 292 bytes | 292.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/SbossS/git-demo.git
555ee70..764e202 master -> master
BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
SbossS:
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ git pull git-demo master
From https://github.com/SbossS/git-demo
* branch master -> FETCH_HEAD
Updating be81036..764e202
Fast-forward
first-demo.txt | 2 ++
1 file changed, 2 insertions(+)
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat
.git/ first-demo.txt
BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
$ cat first-demo.txt
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git
hello git hot-fix
fix finish master
git editing
jiulong edit
jiulong2023
跨团队合作
SSH免密登录
进入用户目录,然后执行ssh-keygen -t rsa -C 邮箱 生成.ssh目录,将公钥拷贝在git设置SSH keys的位置。
BOCO@DESKTOP-8LO1E50 MINGW64 ~
$ pwd
/c/Users/BOCO
BOCO@DESKTOP-8LO1E50 MINGW64 ~
$ ssh-keygen -t rsa -C 邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/BOCO/.ssh/id_rsa):
Created directory '/c/Users/BOCO/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/BOCO/.ssh/id_rsa
Your public key has been saved in /c/Users/BOCO/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:VXmgdV7YDKqVMN3/8o5GtmiSW5YlcVsc5jd6e3TN/Ks 邮箱
The key's randomart image is:
+---[RSA 3072]----+
| o.++oB.|
| *o=*o+|
| o =.o++|
| . o o.==|
| S . ..o.B|
| +=.=|
| .++ =o|
| ooo o.+|
| .+ Eoo.|
+----[SHA256]-----+
BOCO@DESKTOP-8LO1E50 MINGW64 ~
$ cd .ssh/
BOCO@DESKTOP-8LO1E50 MINGW64 ~/.ssh
$ ll
total 5
-rw-r--r-- 1 BOCO 197121 2602 Mar 23 17:40 id_rsa
-rw-r--r-- 1 BOCO 197121 571 Mar 23 17:40 id_rsa.pub
BOCO@DESKTOP-8LO1E50 MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD2d5zdnDozcD/TGkQRuL9cu7/exYply9Uf+T8vitHT0KEKApw6NynK+bTbUa7JCApqEw5XuM2WOy3W8CGb2XXE2H96woITws8xKSV6hQ0e2DXabAIrU7CSb7tSzm/G7cE+xIzEuxUrbICfJG5Hc/f94MWBH4lVuDO/ynbq9cloX5vTiVj35tPymBf0D5cbtOwd3niqLN8SbeyipJ8tXCiN5lxQDifC5IrzzT9bnoRP9orbmAmu7Z2oP6Pxnd4omWWV7ZFF4f230/kSPGIQhq1fPxsrpJBrDglpy1mb6mG8iqhYuUWhHMgBVi5gomiib+Tv1x6BzUjPj1wwcGD1u/FpHxzjQsJt3VxAx75/6kaNSc9AJugDtjRBI1dmexI3xX5OmOiEnNhG3O7TB0MgYjzGLY808eSYFEmmUxtdVPEbWKqxeZhvMygoNLfkJYVL4ui4+PDe3GtgiGK5XLJjBY3NXqT24Y7TDjDwUc8OwjArbBk5ZeuyG4Uas0FyAo2JYbc= 邮箱
IDEA使用git
有些IDEA自身的以及不必要的文件需要忽略
为什么要忽略他们?
答:与项目的实际功能无关,不参与服务器上部署运行。把它们忽略掉能够屏蔽IDE 工具之间的差异。
怎么忽略?
1)创建忽略规则文件 xxxxignore (前缀名随便起,建议是 git.ignore)e
这个文件的存放位置原则上在哪里都可以,为了便于让~/.gitconfig 文件引用,建议也放在用户家目录下e
git.ignore 文件模版内容如下:
# Compiled class file
*.class# Log file
*.log# BlueJ files
*.ctxt# Mobile Tools for Java (J2ME)
.mtj.tmp/# Package Files #
*.jar
*.war
*.nar
*.ear
*.Zip
*.tar.gz
*.rar# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*.classpath
.project
.settings
target
.idea
*.iml
2)在gitconfig 文件中引用忽略配置文件(此文件在 Windows 的家目录中)
[user]
name = smile
email = jiulongyueer@outlook.com
[core]
excludesfile = C:/Users/BOCO/git.ignore
注意: 这里要使用“正斜线 (/)”,不要使用“反斜线 (\)”
file-setting
IDEA切换版本
合并分支
正常合并
站在master分支合并hot-fix
冲突合并
IDEA集成GitHub
用账号密码很难登录
口令登录
生成口令
口令权限点满
分享项目到GitHub
push推送到远程库
默认
是HTTPS方式推送,这里选择ssh推送好点,点击Define Remote
pull拉取远程代码
克隆远程库代码到本地
GITEE使用类似
从git复制代码到Gitee