Git && Github


一、本地库操作命令

本地初始化

git init

# 选择一个目录进入
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest
$ git init
Initialized empty Git repository in D:/DEVELOP/workspace/IntellijIdeaWorkspace/gittest/.git/

注意: .git 目录中存放的是本地库相关的子目录和文件, 不要删除, 也不要胡
乱修改。

设置签名(系统级用户)

git config --global user.name 用户名

git config --global user.email 邮箱

  • 访问范围为当前登录的操作系统的用户范围
  • 信息保存位置 ~/.gitconfig

设置签名(项目/仓库级用户)

git config user.name 用户名

git config user.email 邮箱

  • 仅在当前本地库范围内有效
  • 信息保存位置~/.gitconfig

状态查看

git status

  • 刚初始化仓库时
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git status
On branch masterNo commits yetnothing to commit (create/copy files and use "git add" to track)
  • 刚添加文件还未将其加入暂存区时
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git status
On branch masterNo commits yetUntracked files:(use "git add <file>..." to include in what will be committed)good.txtnothing added to commit but untracked files present (use "git add" to track)
  • 刚把文件通过git add添加到暂存区时
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git status
On branch masterNo commits yetChanges to be committed:(use "git rm --cached <file>..." to unstage)new file:   good.txt
  • 刚把文件通过git commit提交到本地库时
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git status
On branch master
nothing to commit, working tree clean

添加

git add

  • 添加文件到暂存区
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git add good.txt
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
  • 可以通过git rm --cached 文件名的方式将其从暂存区删除
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git rm --cached good.txt
rm 'good.txt'

提交

git commit

  • 将暂存区的内容提交到本地库
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git commit good.txt
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
[master (root-commit) 1f179a5] my first commit1 file changed, 1 insertion(+)create mode 100644 good.txt

git commit -m “提交说明” 文件名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git commit -m "my second commit" good.txt
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
[master 175df83] my second commit1 file changed, 1 insertion(+), 1 deletion(-)

查看历史记录

git log

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git log
commit 42749fa32da8f214b3e4b8fa11999c71051ee714 (HEAD -> master)
Author: helin9s <1024633414@qq.com>
Date:   Sun Jan 19 22:49:44 2020 +0800my third commitcommit 175df83e9e632783d071de955f8b2f3acb6957a0
Author: helin9s <1024633414@qq.com>
Date:   Sun Jan 19 22:46:26 2020 +0800my second commitcommit 1f179a57c3abcdf3e1980d7d1fe14642196485b5
Author: helin9s <1024633414@qq.com>
Date:   Sun Jan 19 22:39:36 2020 +0800my first commit
  • 多屏显示控制方式:
  • 空格向下翻页
  • b 向上翻页
  • q 退出

git log --pretty=oneline

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git log --pretty=oneline
42749fa32da8f214b3e4b8fa11999c71051ee714 (HEAD -> master) my third commit
175df83e9e632783d071de955f8b2f3acb6957a0 my second commit
1f179a57c3abcdf3e1980d7d1fe14642196485b5 my first commit

git log --oneline

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git log --oneline
42749fa (HEAD -> master) my third commit
175df83 my second commit
1f179a5 my first commit

git refolg

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reflog
42749fa (HEAD -> master) HEAD@{0}: commit: my third commit
175df83 HEAD@{1}: commit: my second commit
1f179a5 HEAD@{2}: commit (initial): my first commit

HEAD@{移动到当前版本需要多少步}

版本前进后退

git reset --hard 索引值

# 改变之前
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reflog
42749fa (HEAD -> master) HEAD@{0}: commit: my third commit
175df83 HEAD@{1}: commit: my second commit
1f179a5 HEAD@{2}: commit (initial): my first commit# 版本后退
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reset --hard 1f179a5
HEAD is now at 1f179a5 my first commit# 查看版本
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reflog
1f179a5 (HEAD -> master) HEAD@{0}: reset: moving to 1f179a5
42749fa HEAD@{1}: commit: my third commit
175df83 HEAD@{2}: commit: my second commit
1f179a5 (HEAD -> master) HEAD@{3}: commit (initial): my first commit# 版本前进同理
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reset --hard 42749fa
HEAD is now at 42749fa my third commit# 查看版本
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git reflog
42749fa (HEAD -> master) HEAD@{0}: reset: moving to 42749fa
1f179a5 HEAD@{1}: reset: moving to 1f179a5
42749fa (HEAD -> master) HEAD@{2}: commit: my third commit
175df83 HEAD@{3}: commit: my second commit
1f179a5 HEAD@{4}: commit (initial): my first commit
  • reset 命令的三个参数对比

    1. –soft:仅仅在本地库移动HEAD指针
    2. –mixed:在本地库移动HEAD指针,重置暂存区
    3. –hard:在本地库移动HEAD指针,重置暂存区,重置工作区

删除文件找回

git reset --hard 指针位置

  • 删除操作已经提交到本地库,指针位置指向历史记录(历史版本索引)
  • 删除操作尚未提交到本地库,指针位置使用HEAD

比较文件差异

git diff 文件名

  • 将工作区中的文件和暂存区进行比较

git diff 本地库历史版本 文件名

  • 将工作区中的文件和本地库历史记录比较

git diff

  • 不带文件名比较多个文件
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git diff 42749fa good.txt
diff --git a/good.txt b/good.txt
index e9305b3..d200834 100644
--- a/good.txt
+++ b/good.txt
@@ -1,5 +1 @@aaaaaaaaaaaaa
-bbbbbbbbbbb
-cccccc
-dddddd
-

二、分支管理

创建分支

git branch 分支名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branch hot_fix

查看分支

git branch

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branchhot_fix
* masterhelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branch -v #查看分支并显示最新的修改hot_fix 175df83 my second commit
* master    175df83 my second commit

删除分支

git branch -d 分支名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branch -ahotot_fix
* masterrmhelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branch -d rm
Deleted branch rm (was a520ad8).helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git branchhotot_fix
* master

切换分支

git checkout 分支名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git checkout hot_fix
Switched to branch 'hot_fix'helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (hot_fix)
$ git branch
* hot_fixmaster

合并分支

git merge 有新内容的分支名

# 第一步,先要切换到接受修改的分支(需要增加新内容的分支)上
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (hot_fix)
$ git checkout master
Switched to branch 'master'# 第二步,执行merge命令,合并有新内容的分支
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git merge hot_fix
Updating 175df83..e8876e9
Fast-forwardapple.txt | 2 ++good.txt  | 1 +2 files changed, 3 insertions(+)create mode 100644 apple.txt

解决冲突

# 修改master分支下的good文件并提交
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ vim good.txthelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git commit -m "master commit" good.txt
[master 82d773d] master commit1 file changed, 1 insertion(+), 1 deletion(-)# 切换到hot_fix分支并修改good文件的同样位置
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git checkout hot_fix
Switched to branch 'hot_fix'helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (hot_fix)
$ vim good.txthelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (hot_fix)
$ git commit -m "hot_fix commit" good.txt
[hotot_fix a520ad8] hot_fix commit1 file changed, 3 insertions(+), 1 deletion(-)# 重新切换成master分支,执行合并,出现冲突
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (hot_fix)
$ git checkout master
Switched to branch 'master'helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git merge hot_fix
Auto-merging good.txt
CONFLICT (content): Merge conflict in good.txt
Automatic merge failed; fix conflicts and then commit the result.
  • 解决冲突
# 编辑冲突文件
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master|MERGING)
$ vim good.txt
  • 处理冲突
aaaaaaaaaaaaa
<<<<<<< HEAD       # <<<< HEAD到=====之间是当前分支的内容
bbbb   ccccc
=======
bbbb dddd           #======到>>>>>>> hot_fix之间是hot_fix分支的内容dddd
>>>>>>> hot_fix
  • 提交合并
# 编辑完成后查看当前文件状态,显示还有冲突
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master|MERGING)
$ git status
On branch master
You have unmerged paths.(fix conflicts and run "git commit")(use "git merge --abort" to abort the merge)Unmerged paths:(use "git add <file>..." to mark resolution)both modified:   good.txtno changes added to commit (use "git add" and/or "git commit -a")# 把修改提交到暂存区后标记为合并,但是尚未提交
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master|MERGING)
$ git add good.txthelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master|MERGING)
$ git status
On branch master
All conflicts fixed but you are still merging.(use "git commit" to conclude merge)Changes to be committed:modified:   good.txt# commit完成真正的合并,此处不能加文件名
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master|MERGING)
$ git commit -m "resolve confilct"
[master 3d38ffc] resolve confilct

三、远程仓库操作

查看远程仓库

git remote -v

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote -v

git绑定远程仓库地址

git remote add 仓库别名 仓库地址

# github  origin是仓库地址的别名
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote add origin https://github.com/helin9s/gittest.githelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote -v
origin  https://github.com/helin9s/gittest.git (fetch)
origin  https://github.com/helin9s/gittest.git (push)# gitee
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote add gitee https://gitee.com/helin9S/gittest.githelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote -v
gitee   https://gitee.com/helin9S/gittest.git (fetch)
gitee   https://gitee.com/helin9S/gittest.git (push)

git删除绑定的远程仓库地址

git remote rm 仓库别名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git remote rm origin

git 推送本地分支到远程仓库

git push 仓库别名 分支名

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git push origin master
# 需要输入github或gitee的账号密码
To https://github.com/helin9s/gittest.git! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/helin9s/gittest.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  • 因为创建仓库时生成了readme.md文件

git push -u 仓库别名 分支名 -f

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ git push -u origin master -f
# 强制推送,推送成功
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 12 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (21/21), 1.63 KiB | 556.00 KiB/s, done.
Total 21 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/helin9s/gittest.git+ bd9372f...3d38ffc master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'origin'.
  • 注意:git本身不能保存账号密码,账号密码是通过window的控制面板\所有控制面板项\凭据管理器进行保存的

git克隆远程仓库到本地

git clone 远程仓库地址

helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone
$ git clone https://gitee.com/helin9S/gittest.git
Cloning into 'gittest'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 21 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (21/21), done.
  • 完整的把远程仓库下载到本地
  • 创建origin远程地址别名
  • 初始化本地库

git拉取远程仓库的修改

git pull 远程仓库别名 远程分支名

  • pull=fetch+merge

git fetch 远程仓库别名 远程分支名

  • 下载远程仓库的文件,并不改变本地工作区的文件

git merge 远程仓库别名/远程分支名

  • 合并

SSH登陆

1. 创建密钥

# 进入home目录
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gittest (master)
$ cd ~
# 删除以前的ssh密钥
helin9s@LAPTOP-M719A9K6 MINGW64 ~
$ rm -r .ssh/
rm: cannot remove '.ssh/': No such file or directory
# 生成密钥,需要确认的地方全部回车使用默认,注意,`-C`的C是大写
helin9s@LAPTOP-M719A9K6 MINGW64 ~
$ ssh-keygen -t rsa -C helin9s@163.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/helin9s/.ssh/id_rsa):
Created directory '/c/Users/helin9s/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/helin9s/.ssh/id_rsa.
Your public key has been saved in /c/Users/helin9s/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:4IW6qG1YqktEEbTsGFNyxIS6UizDOlG57sQywlan/CA helin9s@163.com
The key's randomart image is:
+---[RSA 3072]----+
|oO*.             |
|o+*    .         |
|=* .  o .        |
|O++. + o         |
|+@o + . S        |
|XE== .           |
|+@o +            |
|+oo  .           |
|=o.              |
+----[SHA256]-----+

2. 把密钥保存到远程仓库

# 进入.ssh目录
helin9s@LAPTOP-M719A9K6 MINGW64 ~
$ cd .ssh/helin9s@LAPTOP-M719A9K6 MINGW64 ~/.ssh
$ ll
total 5
-rw-r--r-- 1 helin9s 197121 2602  1月 21 16:14 id_rsa
-rw-r--r-- 1 helin9s 197121  569  1月 21 16:14 id_rsa.pub
# 查看id_rsa.pub文件,全部复制
helin9s@LAPTOP-M719A9K6 MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCvnfCr+dxqqo1qGEz4Gt7lTrR9zf26QLXRwwY9LdBi8QIaBend45RfdlZ6mZF6GsSz2IY2JSI1Te7OO6QXJDFCiEz37uJn+31xZ7/vPjyzZSydSmnGlNm0/dCm2P/n0E+xHZ9mCK1vSoNjdRbVYgRcTHpwYLGfR4Y1y5Y3TJrWFyBSzZDiFQZXDNyUv1puRB5cb0LY1fOm8UpQb9utdl4Gk7pPKbYGdFnc0EF5YKaouhEJeQD+3qNTH58UlAFVWWtyu6ZUgvZBBWB1M6Di+4LNNBW6ndfR6WrXrdoraO1lvSQNxaVWgxBkpxSvQtmmCisanhjisK79EJSuhppkYJEARzH0gdHNZI7lCvziwjWOEqhLIWm7/eMxh2rBPppxwVEAc+7Y5UvtAUJSDI1T8ttt17kYKr89EWLzMyUAWPlkpKf4FVMvOXO1DRgnFYpU9H/gIrXFD1kXOy6SeBXnpo8TToa6czC94R2te28MIVb3DKKpqT2+xX0GsxxDuwu73OM= helin9s@163.com

3. 打开github或者gitee

  • 如果是githubsettings->SSH keys->new ssh key,然后把上面复制的密钥全部粘贴保存

  • 如果是gitee设置->SSH公钥,然后把上面复制的密钥全部粘贴保存

4. git客户端访问

# 查看原来的http仓库
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ git remote -v
origin  https://gitee.com/helin9S/gittest.git (fetch)
origin  https://gitee.com/helin9S/gittest.git (push)
# 添加新的ssh仓库
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ git remote add origin_ssh git@gitee.com:helin9S/gittest.githelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ git remote -v
origin  https://gitee.com/helin9S/gittest.git (fetch)
origin  https://gitee.com/helin9S/gittest.git (push)
origin_ssh      git@gitee.com:helin9S/gittest.git (fetch)
origin_ssh      git@gitee.com:helin9S/gittest.git (push)helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ ll
total 2
-rw-r--r-- 1 helin9s 197121 14  1月 21 00:28 apple.txt
-rw-r--r-- 1 helin9s 197121 46  1月 21 00:28 good.txt
# 修改文件并提交到本地库
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ vim apple.txthelin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ git commit -m "apple pen commit" apple.txt
[master 7e17771] apple pen commit1 file changed, 1 insertion(+)
# 推送修改到ssh远程仓库
helin9s@LAPTOP-M719A9K6 MINGW64 /d/DEVELOP/workspace/IntellijIdeaWorkspace/gitclone/gittest (master)
$ git push origin_ssh master
The authenticity of host 'gitee.com (180.97.125.228)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes #输入yes确认
Warning: Permanently added 'gitee.com,180.97.125.228' (ECDSA) to the list of known hosts.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 279 bytes | 279.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To gitee.com:helin9S/gittest.git3d38ffc..7e17771  master -> master

四、git 工作流

概念

​ 在项目开发过程中使用 Git 的方式

分类

1. 集中式工作流

​ 像 SVN 一样, 集中式工作流以中央仓库作为项目所有修改的单点实体。 所有
修改都提交到 Master 这个分支上。
这种方式与 SVN 的主要区别就是开发人员有本地库。Git 很多特性并没有用到。

2. GitFlow 工作流

​ Gitflow 工作流通过为功能开发、 发布准备和维护设立了独立的分支, 让发布
迭代过程更流畅。 严格的分支模型也为大型项目提供了一些非常必要的结构.

3. Forking 工作流

​ Forking 工作流是在 GitFlow 基础上, 充分利用了 Git 的 Fork 和 pull request 的
功能以达到代码审核的目的。 更适合安全可靠地管理大团队的开发者, 而且能接受
不信任贡献者的提交。

五、Gitlab 服务器搭建过程

官网地址

​ 首页: https://about.gitlab.com/
​ 安装说明: https://about.gitlab.com/installation/

安装、配置、访问

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshdsudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalldsudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfixcurl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bashsudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ee# 初始化配置 gitlab
gitlab-ctl reconfigure
# 启动 gitlab 服务
gitlab-ctl start
# 停止 gitlab 服务
gitlab-ctl stop
# 通过ip进行访问
http://服务器ip
  • 设置域名访问
# 修改配置文件
$ vim /etc/gitlab/gitlab.rb
………………
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
# external_url 'http://gitlab.example.com'
# 能够解析
external_url 'http://gitlab.helin9s.cn'#配置启动
$ gitlab-ctl reconfigure

GitLab常用命令

gitlab-ctl start    # 启动所有 gitlab 组件;
gitlab-ctl stop        # 停止所有 gitlab 组件;
gitlab-ctl restart        # 重启所有 gitlab 组件;
gitlab-ctl status        # 查看服务状态;
gitlab-ctl reconfigure        # 启动服务;
vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件;
gitlab-ctl tail        # 查看日志;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;

GitLab卸载

# 停止gitlab
[root@localhost ~]$ gitlab-ctl stop
# 查看gitlab进程
[root@localhost ~]$ ps -aux|grep gitlab
# 如果有进程则杀掉
[root@localhost ~]$ ps -9 gitlab的PID
# 卸载gitlab
[root@localhost ~]$ rpm -e gitlab-ee
# 删除gitlab的所有文件
[root@localhost ~]$ find / -name gitlab|xargs rm -rf

Git Github学习笔记相关推荐

  1. git/github学习笔记

    原文地址为: git/github学习笔记 请移步到:http://www.testclass.net/git/ ----- 我重新对git/github教程进行了编排和整理. 1. git 版本控制 ...

  2. 《Got Git》学习笔记(一)

    <Got Git>学习笔记(一) 最近想对自己的代码和文档进行归档整理,需要一个版本控制系统来进行 处理.自然而然的想到了目前流行的GitHub. GitHub,是一个面向开源及私有软件项 ...

  3. git的学习笔记(二):git远程操作

    git的学习笔记(一):git本地操作 1.创建ssh key ssh-keygen -t rsa -C "your_email@example.com" 执行命令后会在用户的家目 ...

  4. Git 个人学习笔记及心得

    作为程序员如果你还不知道 Git 和 GitHub,说不过去吧,赶紧来学习一波. 一.认识GitHub Git 是个版本控制系统,说明白点就是进行代码的各种管理,比如你写错代码进行回滚啊.追寻 Bug ...

  5. Git 经验总结及 Git GitHub 学习指南

    1. 前言 本文主要分为两部分,前一部分是本人学习和工作中使用 Git 的总结经验,后半部分是总结的 Git & GitHub 的学习指南.如果想直接体系学习,可以直接按照指南路线学习.如果你 ...

  6. Learn Git Branching 学习笔记(移动提交记录篇)

    目录 一.移动提交记录篇 1.Git Cherry-pick 2.交互式rebase Git用法高级篇在上一篇文章中Learn Git Branching 学习笔记(高级篇)_流年--by gone的 ...

  7. Learn Git Branching 学习笔记(高级话题篇)

    目录 一.高级话题篇 1.多分支rebase 2.选择父提交记录 3.纠缠不清的分支 Git的一些技术.技巧与贴士集合在上一篇文章中 Learn Git Branching 学习笔记(Git 技术.技 ...

  8. git与github学习笔记

    认识Git 是一个强大的分布式版本控制工具 分布式:可以协作,任务可以拆分:每次的改动都有记录,版本可以控制 强大的分支管理 直接记录快照,而非差异比较 关心文件数据的整体是否发生变化,而非文件内容的 ...

  9. 廖雪峰Git教程学习笔记

    廖雪峰git简单教程学习笔记 教程地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b ...

最新文章

  1. python控制手机发短信_python-在python3中使用容联云通讯发送短信验证码
  2. 心急的C小加《贪心》
  3. 模拟浏览器自动化测试工具Selenium之七采集网页信息写入excel
  4. python绘图使用subplots出现标题重叠的解决方法
  5. [HDU1394]Minimum Inversion Number
  6. mysql find()方法_Mysql find_in_set()函数使用方法
  7. mysql防止误删除_mysql误删除处理方法
  8. undefined: grpc.SupportPackageIsVersion6 和 undefined: grpc.ClientConnInterface 解决办法
  9. JNI之C语言简单回顾
  10. 运行报错error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
  11. python多线程有用吗_当CPU利用率已经接近100%时,多线程有帮助吗?
  12. PAT乙级 1032 挖掘机技术哪家强 (20 分)
  13. 漫画:如何给初学者讲“为什么计算机只认识 0 和 1”?
  14. 汽车销售管理系统源码
  15. 斐讯n1刷linux配置wifi,斐讯N1刷CentOS7最简操作
  16. 数据库设计-UML模型
  17. Lab4 Architecture Lab
  18. STM32硬件实现 CRC-16/MODBUS
  19. 数值分析复习(一)线性插值、抛物线插值
  20. 持续爆点:一对一直播和短视频

热门文章

  1. 微信定向流量_中国移动终于投诚了!微信惊现10G流量包,只要10元?
  2. 制作简易的牛顿摆锤模型
  3. python实现网络与IP地址计算
  4. 机器人鸣人是哪一集_火影忍者596集剧情介绍番外篇九尾抢夺指令_鸣人VS机器人版鸣人...
  5. C# 调用微信接口上传素材和发送图文消息
  6. 用Android做的一个简单的视频播放器
  7. css3的媒体查询(Media Queries)
  8. vue 微信录音倒计时_vue的微信语音功能,录音+对接口返回amr音频播放-Go语言中文社区...
  9. navicat导入excel表中数据出错问题
  10. 免费稳定的APP分发托管平台,支持应用合并、内测分发、扫码下载