当前位置:   article > 正文

git使用笔记_gerrit怎样修改配置的邮箱

gerrit怎样修改配置的邮箱

 常用命令

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 "你的邮箱"
 

  1. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo
  2. #初始化本地目录
  3. $ git init
  4. Initialized empty Git repository in D:/file/gitspace/git-demo/.git/
  5. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  6. $ ll
  7. total 0
  8. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  9. $ ll -a
  10. total 4
  11. drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 ./
  12. drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 ../
  13. drwxr-xr-x 1 BOCO 197121 0 Mar 21 17:32 .git/
  14. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  15. $ ll
  16. total 0
  17. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  18. $ vi first-demo.txt
  19. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  20. $ git status
  21. On branch master
  22. No commits yet
  23. Untracked files:
  24. (use "git add <file>..." to include in what will be committed)
  25. first-demo.txt
  26. nothing added to commit but untracked files present (use "git add" to track)
  27. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  28. #添加暂存区
  29. $ git add first-demo.txt
  30. warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
  31. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  32. $ git status
  33. On branch master
  34. No commits yet
  35. Changes to be committed:
  36. (use "git rm --cached <file>..." to unstage)
  37. new file: first-demo.txt
  38. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  39. #删除暂存区
  40. $ git rm --cached first-demo.txt
  41. rm 'first-demo.txt'
  42. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  43. $ git status
  44. On branch master
  45. No commits yet
  46. Untracked files:
  47. (use "git add <file>..." to include in what will be committed)
  48. first-demo.txt
  49. nothing added to commit but untracked files present (use "git add" to track)
  50. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  51. $ ll
  52. total 1
  53. -rw-r--r-- 1 BOCO 197121 81 Mar 21 17:41 first-demo.txt
  54. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  55. $ git add first-demo.txt
  56. warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
  57. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  58. #提交本地库
  59. $ git commit -m "first commit" first-demo.txt
  60. warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
  61. [master (root-commit) e2d4217] first commit
  62. 1 file changed, 9 insertions(+)
  63. create mode 100644 first-demo.txt
  64. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  65. $ git status
  66. On branch master
  67. nothing to commit, working tree clean
  68. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  69. $ git log
  70. commit e2d4217ecfdb63e0c0a4b6de6e90bb9232b50e30 (HEAD -> master)
  71. Author: smile <jiulongyueer@outlook.com>
  72. Date: Tue Mar 21 17:42:32 2023 +0800
  73. first commit
  74. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  75. $ git relog
  76. git: 'relog' is not a git command. See 'git --help'.
  77. The most similar command is
  78. reflog
  79. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  80. $ git reflog
  81. e2d4217 (HEAD -> master) HEAD@{0}: commit (initial): first commit
  82. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  83. $
  84. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  85. $ vi first-demo.txt
  86. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  87. #修改文件内容12345678
  88. $ cat first-demo.txt
  89. hello git
  90. hello git
  91. 12345678
  92. hello git
  93. hello git
  94. hello git
  95. hello git
  96. hello git
  97. hello git
  98. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  99. $ git status
  100. On branch master
  101. Changes not staged for commit:
  102. (use "git add <file>..." to update what will be committed)
  103. (use "git restore <file>..." to discard changes in working directory)
  104. modified: first-demo.txt
  105. no changes added to commit (use "git add" and/or "git commit -a")
  106. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  107. $ git add first-demo.txt
  108. warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
  109. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  110. $ git commit -m "second commit" first-demo.txt
  111. warning: in the working copy of 'first-demo.txt', LF will be replaced by CRLF the next time Git touches it
  112. [master 8a4ea4f] second commit
  113. 1 file changed, 1 insertion(+), 1 deletion(-)
  114. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  115. $ git status
  116. On branch master
  117. nothing to commit, working tree clean
  118. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  119. $ git reflog
  120. 8a4ea4f (HEAD -> master) HEAD@{0}: commit: second commit
  121. e2d4217 HEAD@{1}: commit (initial): first commit
  122. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)

版本穿梭

  1. $ git reflog
  2. 8a4ea4f (HEAD -> master) HEAD@{0}: commit: second commit
  3. e2d4217 HEAD@{1}: commit (initial): first commit
  4. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  5. $ ^C
  6. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  7. $ git log
  8. commit 8a4ea4fa40ce2adf9553998ffcccd8af4bedb14a (HEAD -> master)
  9. Author: smile <jiulongyueer@outlook.com>
  10. Date: Wed Mar 22 11:28:28 2023 +0800
  11. second commit
  12. commit e2d4217ecfdb63e0c0a4b6de6e90bb9232b50e30
  13. Author: smile <jiulongyueer@outlook.com>
  14. Date: Tue Mar 21 17:42:32 2023 +0800
  15. first commit
  16. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  17. $ git reset --hard 8a4ea4f
  18. HEAD is now at 8a4ea4f second commit
  19. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  20. $ git reflog
  21. 8a4ea4f (HEAD -> master) HEAD@{0}: reset: moving to 8a4ea4f
  22. 8a4ea4f (HEAD -> master) HEAD@{1}: commit: second commit
  23. e2d4217 HEAD@{2}: commit (initial): first commit
  24. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  25. $ cat first-demo.txt
  26. hello git
  27. hello git
  28. 12345678
  29. hello git
  30. hello git
  31. hello git
  32. hello git
  33. hello git
  34. hello git
  35. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  36. $ git reset --hard e2d4217
  37. HEAD is now at e2d4217 first commit
  38. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  39. $ git reflog
  40. e2d4217 (HEAD -> master) HEAD@{0}: reset: moving to e2d4217
  41. 8a4ea4f HEAD@{1}: reset: moving to 8a4ea4f
  42. 8a4ea4f HEAD@{2}: commit: second commit
  43. e2d4217 (HEAD -> master) HEAD@{3}: commit (initial): first commit
  44. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  45. $ cat first-demo.txt
  46. hello git
  47. hello git
  48. hello git
  49. hello git
  50. hello git
  51. hello git
  52. hello git
  53. hello git
  54. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  55. $

 Git分支

在版本控制过程中,同时推进多个任务,为每个任务,我们就可以创建每个任务的单独分支。使用分支意味着程序员可以把自己的工作从开发主线上分离开来,开发自己分支的时候,不会影响主线分支的运行。对于初学者而言,分支可以简单理解为副本,一个分支就是一个单独的副本。(分支底层其实也是指针的引用)

 分支的操作:

命令名称作用
git branch 分支名创建分支
git branch -v查看分支
git checkout 分支名切换分支
git merge 分支名把指定的分支合并到当前分支上

新建一个分支,然后切换分支hot-fix修改文件,修改后回到master分支查看。

  1. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  2. $ cat first-demo.txt
  3. hello git
  4. hello git
  5. hello git
  6. hello git
  7. hello git
  8. hello git
  9. hello git
  10. hello git
  11. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  12. $ ^C
  13. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  14. $ git branch hot-fix
  15. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  16. $ git branch -v
  17. hot-fix e2d4217 first commit
  18. * master e2d4217 first commit
  19. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  20. $ git checkout hot-fix
  21. Switched to branch 'hot-fix'
  22. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  23. $ vim first-demo.txt
  24. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  25. $ cat first-demo.txt
  26. hello git
  27. hello git
  28. hello git
  29. hello git
  30. hello git
  31. hello git
  32. hello git
  33. hello git
  34. fix finish
  35. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  36. $ git status
  37. On branch hot-fix
  38. Changes not staged for commit:
  39. (use "git add <file>..." to update what will be committed)
  40. (use "git restore <file>..." to discard changes in working directory)
  41. modified: first-demo.txt
  42. no changes added to commit (use "git add" and/or "git commit -a")
  43. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  44. $ git add first-demo.txt
  45. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  46. $ git commit -m "hot-fix first commit" first-demo.txt
  47. [hot-fix 0876f30] hot-fix first commit
  48. 1 file changed, 1 insertion(+), 1 deletion(-)
  49. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  50. $ git checkout master
  51. Switched to branch 'master'
  52. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  53. $ cat first-demo.txt
  54. hello git
  55. hello git
  56. hello git
  57. hello git
  58. hello git
  59. hello git
  60. hello git
  61. hello git
  62. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)

 合并分支

  1. $ git merge hot-fix
  2. Updating e2d4217..0876f30
  3. Fast-forward
  4. first-demo.txt | 2 +-
  5. 1 file changed, 1 insertion(+), 1 deletion(-)
  6. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  7. $ cat first-demo.txt
  8. hello git
  9. hello git
  10. hello git
  11. hello git
  12. hello git
  13. hello git
  14. hello git
  15. hello git
  16. fix finish
  17. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  18. $

合并冲突:当两个版本之间合并时发生冲突,需要手动合并

  1. $ cat first-demo.txt
  2. hello git
  3. hello git
  4. hello git
  5. hello git
  6. hello git
  7. hello git
  8. hello git
  9. hello git
  10. fix finish master
  11. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  12. $ git add first-demo.txt
  13. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  14. $ git commit -m "master first-test commit" first-demo.txt
  15. [master 09fe8f2] master first-test commit
  16. 1 file changed, 1 insertion(+), 1 deletion(-)
  17. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  18. $ git checkout hot-fix
  19. Switched to branch 'hot-fix'
  20. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  21. $ cat first-demo.txt
  22. hello git
  23. hello git
  24. hello git
  25. hello git
  26. hello git
  27. hello git
  28. hello git
  29. hello git
  30. fix finish
  31. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  32. $ vi first-demo.txt
  33. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  34. $ cat first-demo.txt
  35. hello git
  36. hello git
  37. hello git
  38. hello git
  39. hello git
  40. hello git
  41. hello git
  42. hello git hot-fix
  43. fix finish
  44. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  45. $ git add first-demo.txt
  46. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  47. $ git commit -m "hot-fix second commit" first-demo.txt
  48. [hot-fix b55f4de] hot-fix second commit
  49. 1 file changed, 1 insertion(+), 1 deletion(-)
  50. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  51. $ git checkout master
  52. Switched to branch 'master'
  53. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  54. $ git merge hot-fix
  55. Auto-merging first-demo.txt
  56. CONFLICT (content): Merge conflict in first-demo.txt
  57. Automatic merge failed; fix conflicts and then commit the result.
  58. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  59. $ cat first-demo.txt
  60. hello git
  61. hello git
  62. hello git
  63. hello git
  64. hello git
  65. hello git
  66. hello git
  67. <<<<<<< HEAD
  68. hello git
  69. fix finish master
  70. =======
  71. hello git hot-fix
  72. fix finish
  73. >>>>>>> hot-fix
  74. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  75. $ vi first-demo.txt
  76. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  77. $ git merge hot-fix
  78. error: Merging is not possible because you have unmerged files.
  79. hint: Fix them up in the work tree, and then use 'git add/rm <file>'
  80. hint: as appropriate to mark resolution and make a commit.
  81. fatal: Exiting because of an unresolved conflict.
  82. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  83. $ git add first-demo.txt
  84. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  85. #这里手动合并后不能跟文件名
  86. $ git commit -m "test merge" first-demo.txt
  87. fatal: cannot do a partial commit during a merge.
  88. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master|MERGING)
  89. $ git commit -m "test merge"
  90. [master 04c1998] test merge
  91. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  92. $ cat first-demo.txt
  93. hello git
  94. hello git
  95. hello git
  96. hello git
  97. hello git
  98. hello git
  99. hello git
  100. hello git
  101. hello git hot-fix
  102. fix finish master
  103. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  104. $ git checkout hot-fix
  105. Switched to branch 'hot-fix'
  106. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  107. $ cat first-demo.txt
  108. hello git
  109. hello git
  110. hello git
  111. hello git
  112. hello git
  113. hello git
  114. hello git
  115. hello git hot-fix
  116. fix finish
  117. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  118. $

创建远程仓库:

 

 选择public,私有的有人数限制,多人建议自己搭建gitlab

 创建成功

然后创建远程库别名

基本语法:

git remote-v  查看当前所有远程地址别名

git remote add    别名  远程地址

  1. $ git remote -v
  2. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  3. $ git remote add git-demo https://github.com/SbossS/git-demo.git
  4. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  5. $ git remote -v
  6. git-demo https://github.com/SbossS/git-demo.git (fetch)
  7. git-demo https://github.com/SbossS/git-demo.git (push)
  8. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (hot-fix)
  9. $ git checkout master
  10. Switched to branch 'master'
  11. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  12. $ ll
  13. total 1
  14. -rw-r--r-- 1 BOCO 197121 128 Mar 23 10:29 first-demo.txt
  15. #想远程仓库推送代码
  16. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  17. $ git push git-demo master
  18. Enumerating objects: 15, done.
  19. Counting objects: 100% (15/15), done.
  20. Delta compression using up to 4 threads
  21. Compressing objects: 100% (10/10), done.
  22. Writing objects: 100% (15/15), 1.14 KiB | 25.00 KiB/s, done.
  23. Total 15 (delta 5), reused 0 (delta 0), pack-reused 0
  24. remote: Resolving deltas: 100% (5/5), done.
  25. To https://github.com/SbossS/git-demo.git
  26. * [new branch] master -> master
  27. #从远程仓库拉取代码
  28. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  29. $ git pull git-demo master
  30. remote: Enumerating objects: 5, done.
  31. remote: Counting objects: 100% (5/5), done.
  32. remote: Compressing objects: 100% (2/2), done.
  33. remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
  34. Unpacking objects: 100% (3/3), 661 bytes | 1024 bytes/s, done.
  35. From https://github.com/SbossS/git-demo
  36. * branch master -> FETCH_HEAD
  37. 04c1998..be81036 master -> git-demo/master
  38. Updating 04c1998..be81036
  39. Fast-forward
  40. first-demo.txt | 1 +
  41. 1 file changed, 1 insertion(+)
  42. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  43. $ ll
  44. total 1
  45. -rw-r--r-- 1 BOCO 197121 141 Mar 23 10:39 first-demo.txt
  46. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  47. $ cat first-demo.txt
  48. hello git
  49. hello git
  50. hello git
  51. hello git
  52. hello git
  53. hello git
  54. hello git
  55. hello git
  56. hello git hot-fix
  57. fix finish master
  58. git editing
  59. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  60. $

团队内合作

克隆远程仓库到本地

git clone 地址

两个账号  jiulong2023  SbossS 切换账号时需要删除凭据管理器里原来的账号

流程:新建 jiulong2023账号的目录,进入bash,然后clone文件,修改文件,add commit,退出SbossS 账号,用 jiulong2023账号登录git,SbossS 邀请 jiulong2023加入collaborators,然后jiulong2023提交远程仓库,然后删除凭据管理器里jiulong2023,切换到SbossS本地路径下pull代码。

bossS 邀请 jiulong2023加入collaborators

 jiulong2023:

  1. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong
  2. $ git clone https://github.com/SbossS/git-demo.git
  3. Cloning into 'git-demo'...
  4. remote: Enumerating objects: 18, done.
  5. remote: Counting objects: 100% (18/18), done.
  6. remote: Compressing objects: 100% (7/7), done.
  7. remote: Total 18 (delta 6), reused 14 (delta 5), pack-reused 0
  8. Receiving objects: 100% (18/18), done.
  9. Resolving deltas: 100% (6/6), done.
  10. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong
  11. $ cd git-demo/
  12. '
  13. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  14. $
  15. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  16. $ ll
  17. total 1
  18. -rw-r--r-- 1 BOCO 197121 141 Mar 23 11:21 first-demo.txt
  19. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  20. $ vi first-demo.txt
  21. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  22. $ git remote -v
  23. origin https://github.com/SbossS/git-demo.git (fetch)
  24. origin https://github.com/SbossS/git-demo.git (push)
  25. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  26. $ git add first-demo.txt
  27. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  28. $ git commit -m "jiulong2023 commit" first-demo.txt
  29. [master 555ee70] jiulong2023 commit
  30. 1 file changed, 1 insertion(+)
  31. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)
  32. $ git push origin master
  33. Enumerating objects: 5, done.
  34. Counting objects: 100% (5/5), done.
  35. Delta compression using up to 4 threads
  36. Compressing objects: 100% (2/2), done.
  37. Writing objects: 100% (3/3), 292 bytes | 292.00 KiB/s, done.
  38. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
  39. remote: Resolving deltas: 100% (1/1), completed with 1 local object.
  40. To https://github.com/SbossS/git-demo.git
  41. 555ee70..764e202 master -> master
  42. BOCO@DESKTOP-8LO1E50 MINGW64 /d/jiulong/git-demo (master)

 SbossS:

  1. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  2. $ git pull git-demo master
  3. From https://github.com/SbossS/git-demo
  4. * branch master -> FETCH_HEAD
  5. Updating be81036..764e202
  6. Fast-forward
  7. first-demo.txt | 2 ++
  8. 1 file changed, 2 insertions(+)
  9. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  10. $ cat
  11. .git/ first-demo.txt
  12. BOCO@DESKTOP-8LO1E50 MINGW64 /d/file/gitspace/git-demo (master)
  13. $ cat first-demo.txt
  14. hello git
  15. hello git
  16. hello git
  17. hello git
  18. hello git
  19. hello git
  20. hello git
  21. hello git
  22. hello git hot-fix
  23. fix finish master
  24. git editing
  25. jiulong edit
  26. jiulong2023

 跨团队合作

SSH免密登录

进入用户目录,然后执行ssh-keygen -t rsa -C 邮箱 生成.ssh目录,将公钥拷贝在git设置SSH keys的位置。

  1. BOCO@DESKTOP-8LO1E50 MINGW64 ~
  2. $ pwd
  3. /c/Users/BOCO
  4. BOCO@DESKTOP-8LO1E50 MINGW64 ~
  5. $ ssh-keygen -t rsa -C 邮箱
  6. Generating public/private rsa key pair.
  7. Enter file in which to save the key (/c/Users/BOCO/.ssh/id_rsa):
  8. Created directory '/c/Users/BOCO/.ssh'.
  9. Enter passphrase (empty for no passphrase):
  10. Enter same passphrase again:
  11. Your identification has been saved in /c/Users/BOCO/.ssh/id_rsa
  12. Your public key has been saved in /c/Users/BOCO/.ssh/id_rsa.pub
  13. The key fingerprint is:
  14. SHA256:VXmgdV7YDKqVMN3/8o5GtmiSW5YlcVsc5jd6e3TN/Ks 邮箱
  15. The key's randomart image is:
  16. +---[RSA 3072]----+
  17. | o.++oB.|
  18. | *o=*o+|
  19. | o =.o++|
  20. | . o o.==|
  21. | S . ..o.B|
  22. | +=.=|
  23. | .++ =o|
  24. | ooo o.+|
  25. | .+ Eoo.|
  26. +----[SHA256]-----+
  27. BOCO@DESKTOP-8LO1E50 MINGW64 ~
  28. $ cd .ssh/
  29. BOCO@DESKTOP-8LO1E50 MINGW64 ~/.ssh
  30. $ ll
  31. total 5
  32. -rw-r--r-- 1 BOCO 197121 2602 Mar 23 17:40 id_rsa
  33. -rw-r--r-- 1 BOCO 197121 571 Mar 23 17:40 id_rsa.pub
  34. BOCO@DESKTOP-8LO1E50 MINGW64 ~/.ssh
  35. $ cat id_rsa.pub
  36. 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 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/427927
推荐阅读
相关标签
  

闽ICP备14008679号