git基本命令

随时补充

920 创建: 2019/9/20 08:00 更新: 2022/5/28 12:50 本文总阅读量

»
基本用法

基本

git中文手册
易百

当前代码放入缓存区做准备:

git add ./

提交到本地并注释(wu):

git commit -m wu

推送到远程服务器:

git push origin yangzhou

切换分支:

git checkout yangzhou

切换之后更新一下分支:

git pull origin yangzhou

注意:切换分支前先提交一下

拉取远程分支(拉取所有新的)

git fetch

拉取远程制定分支

git fetch origin XXX

»
保留但不产生commit

保留但不产生commit

  • 适用于:更改了A分支的某些代码,这时候需要切换B分支处理事务,但是由于A没有写完,不想产生commit,在处理完B后回来接着写A
 ## 保存A的修改
 git stash push -u -m "暂存A的修改"

 ## 处理完事务,回到A后执行
 git stash pop

 ## 查看暂存信息
 git stash list 


»
多仓库,一个保持所有记录,一个按功能记录

多仓库: 详细记录、按功能记录

  • 需求:
  • 同一份代码关联两两个仓库分别为at920origin
  • 其中初始代码是一样的,之后我又向at920提交了3次但未向origin提交,我想将这三次commit合并为一次提交到origin,但不要影响at920的commit记录

at920仓库为详细每一次的commit记录;origin仓库为简要记录.

## 1.确保当前在main分支并拉取at920的最新提交:

git checkout main
git pull at920 main

## 2.创建临时分支,基于origin/main(确保与 origin 的 main 保持一致):

git checkout -b temp-squash origin/main

## 3.将at920/main的 3 次提交压缩合并到临时分支:

git merge --squash at920/main

## 4.提交压缩后的更改(这会生成一个新的提交):

git add .
git commit -m "合并at920的3次提交内容"

## 5.将压缩后的提交推送到origin/main

git push origin temp-squash:main

## 6.回到原分支并清理临时分支

git checkout main
git branch -d temp-squash

完整日志


~/Desktop/muti main % git checkout main 

Already on 'main'
Your branch is ahead of 'origin/main' by 3 commits.
  (use "git push" to publish your local commits)

~/Desktop/muti main % git pull at920 main 

From https://gitee.com/At920/muti
 * branch            main       -> FETCH_HEAD
Already up to date.

~/Desktop/muti main % git checkout -b temp-squash origin/main 

branch 'temp-squash' set up to track 'origin/main'.
Switched to a new branch 'temp-squash'

~/Desktop/muti temp-squash % git merge --squash at920/main 

Updating 64e8fb3..e556a43
Fast-forward
Squash commit -- not updating HEAD
 test.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

~/Desktop/muti temp-squash * % git add ./

~/Desktop/muti temp-squash * % git commit -m '合并3次记录为一次'

[temp-squash 2043927] 合并3次记录为一次
 1 file changed, 4 insertions(+), 1 deletion(-)

~/Desktop/muti temp-squash % git push origin temp-squash:main 

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 318 bytes | 318.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:yznote/multi.git
   64e8fb3..2043927  temp-squash -> main

~/Desktop/muti temp-squash % git checkout main 

Switched to branch 'main'
Your branch and 'origin/main' have diverged,
and have 3 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

~/Desktop/muti main % git branch
* main
  temp-squash

~/Desktop/muti main % git branch -d temp-squash 

warning: deleting branch 'temp-squash' that has been merged to
         'refs/remotes/origin/main', but not yet merged to HEAD.
Deleted branch temp-squash (was 2043927).

~/Desktop/muti main % git branch 

* main

~/Desktop/muti main % git remote -v

at920   https://gitee.com/At920/muti.git (fetch)
at920   https://gitee.com/At920/muti.git (push)
origin  git@github.com:yznote/multi.git (fetch)
origin  git@github.com:yznote/multi.git (push)

~/Desktop/muti main % git log at920/main ^origin/main --oneline 

e556a43 (HEAD -> main, at920/main) diff-3
9b79245 diff-2
78909a3 diff-1

~/Desktop/muti main % git log at920/main 

commit e556a4305a908044f1e5967cbf0153a48d31b99b (HEAD -> main, at920/main)
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:38:52 2025 +0800

    diff-3

commit 9b7924553507570d88eb1776f5a55bf3215e1732
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:36:56 2025 +0800

    diff-2

commit 78909a3004914068f64ac5f2e221dcbd6052db6a
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:36:12 2025 +0800

    diff-1

commit 64e8fb3d2fb27b031313e37bd0936c125a7fb09a
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:27:37 2025 +0800

    first

~/Desktop/muti main % git log origin/main 

commit 2043927c587add9a748b738fb2d6716733524cab (origin/main)
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:49:06 2025 +0800

    合并3次记录为一次

commit 64e8fb3d2fb27b031313e37bd0936c125a7fb09a
Author: yuan <yzyuan920@163.com>
Date:   Tue Aug 12 10:27:37 2025 +0800

    first

»
SPM

SPM

xcodebuild -resolvePackageDependencies

xcodebuild -resolvePackageDependencies -scmProvider system
  • 阿里云镜像不可用
# 启用 SPM 镜像支持
defaults write com.apple.dt.Xcode IDEPackageSupportUseSPMUI -bool YES

# 设置阿里云 SPM 镜像
defaults write com.apple.dt.Xcode IDESwiftPackageIndexURL -string "https://mirrors.aliyun.com/swift-package-index/"

# 检查配置是否成功
defaults read com.apple.dt.Xcode IDESwiftPackageIndexURL

# 清除 SPM 缓存
rm -rf ~/Library/Caches/org.swift.swiftpm/

# 重启 Xcode 后,SPM 会重新从镜像下载索引

# 恢复到默认的 SPM 索引
defaults delete com.apple.dt.Xcode IDESwiftPackageIndexURL

»
保持线性

dev拉取master的更新,并rebase保持线性

## 1.切到dev
git checkout dev

## 2.拉取master最新
git pull origin master --rebase

## 3.解决冲突(如果有)
git add xx/xx文件

## 4.继续rebase
git rebase --continue

## 5.解决完所有冲突,会进入编辑模式,编辑日志

i -> 进入编辑
Esc -> 退出编辑
:wq -> 保存退出

## 6.查看刚才编辑的内容
git log
日志如下:
    rebase会把dev的所有更改操作重新嫁接到master与dev最后一次分叉的提交之后。例如:【首页分类url_name、Facebook脚本、商品详情h1】,从而保持日志线性

## 注意继续看#7.

rebase 日志【pc-i18n==dev;pc==master】

~/Desktop/uni/3-hk/hk-pc pc-i18n % git log
commit 3e5b0d81758131f0c3081227be22aa607c1e7496 (HEAD -> pc-i18n)   ===> 哈希值会变
Author: yuan <yzyuan920@163.com>
Date:   Thu Jul 31 14:33:34 2025 +0800

    i18n-0731-pages/order_status

commit 79678cc5ecabe7b2c47cc459129ec212197db5d2                     ===> 哈希值会变
Author: yuan <yzyuan920@163.com>
Date:   Wed Jul 30 15:37:54 2025 +0800

    i18n-0730-pages/coupon_center

commit a94b631e50f119cdc69cd02038c92539a35894f1                     ===> 哈希值会变
Author: yuan <yzyuan920@163.com>
Date:   Tue Jul 22 16:46:54 2025 +0800

    i18n-backup-nuxt.config.js                      ======> dev分支的更改

commit d47d70ba2589560ab2fc77484fbc706059d14413 (origin/pc, at920/pc, pc)
Author: yuan <yzyuan920@163.com>
Date:   Thu Jul 31 15:04:54 2025 +0800

    首页分类url_name、Facebook脚本、商品详情h1          ======> master 的更新

commit 260e19813f366c67ccf9b777dc8e03e8ab525a86
Author: yuan <yzyuan920@163.com>
Date:   Fri Jul 18 11:23:51 2025 +0800

    首页文字+文章标题h1                                ======> dev分叉,此处是dev和master的最后一次交集

commit cd7b7cc45fc8c6e2d4971b65bc128b36b3190476
Author: yuan <yzyuan920@163.com>
Date:   Wed Jun 11 09:48:14 2025 +0800

    文档20250522-bugfix、seo、h5-pc互跳

commit f6b50dbfee84bda61ffbf1714bb9c9c43ca15873
Author: lv <121686076@qq.com>
Date:   Tue May 13 16:57:49 2025 +0800

    bug修复、url naming、分类样式

commit 07e9f0aa6b59678a11b301f18e917b1735b09bf2
Author: lv <121686076@qq.com>
Date:   Sat May 10 14:15:45 2025 +0800

    20250510 源码
接着#6继续
## 7.!!注意!!rebase之后本地的commit哈希值和远程的哈希值会不同

## 8.dev再次向远程提交因commit哈希改变会报错
// 拉取远程最新信息、标签但不同步代码
git fetch at920
// 执行强制推送
git push at920 dev --force-with-lease

## 9.通知成员拉取新代码
git pull --rebase

git pull –rebase

  • 与普通 git pull(默认会产生合并提交)不同,git pull –rebase 会将本地所有未推送的提交,按照提交顺序重新应用到远程分支的最新版本上,最终形成一条没有分叉的线性历史,更整洁易读。
  • 当远程分支有新提交时,普通 pull 会生成一个额外的合并提交(记录「合并远程更新」的操作),而 –rebase 会通过改写本地提交的父节点,消除这种多余的合并记录。
  • 假设远程分支有新提交 C2,你本地有未推送的提交 D1
    远程: A → B → C1 → C2
    本地: A → B → C1 → D1
    
  • 执行 git pull –rebase 后,本地历史会变成:
    本地: A → B → C1 → C2 → D1'(D1的副本,哈希值改变)
    

»
合并

将dev代码合并到master

## 1.切换到dev分支(如果还没有在dev分支上):
git checkout dev

## 2.拉取master分支最新的更改:
git pull origin master

## 3.解决合并冲突(如果有的话):

## 4.切换到master分支:
git checkout master

## 5.合并dev分支到master分支:
git merge dev

## 6.次解决合并冲突(如果有的话):

## 7.提交合并后的更改:
git commit -m "merge dev to master"

## 8.将更改推送到远程master分支:
git push origin master

»
合并某一次

dev的某一次commit提交到master

  • 说明:dev分支有开发并且又多次commit,只想将某一次commit合并到master
## 1. 切换到目标分支-`master`
git checkout master

## 2. 找到要`cherry-pick`的提交:使用以下命令查看分支B的提交历史,并找到您想要合并的提交的哈希值
git log dev

## 3. `cherry-pick`指定的提交:使用`cherry-pick`命令将特定提交合并到目标分支(例如分支`master`)
git cherry-pick efcfb5b89a6cc45e0f5d291689d0923f7e67a230

## 4.解决可能出现的冲突
git add <conflicted-file>
git cherry-pick --continue

例如日志:
Auto-merging YBLive.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in YBLive.xcodeproj/project.pbxproj
Auto-merging YBLive/公共方法类/YBToolClass.m
Auto-merging YBLive/直播(开始观看直播)/Agora/YBAgoraManager.m
Auto-merging YBLiveScreen/SampleHandler.m
CONFLICT (content): Merge conflict in YBLiveScreen/SampleHandler.m
error: could not apply efcfb5b8... 客户反馈功能补充以及bugfix

找到 CONFLICT 标记的文件,手动修改 然后 
git add ./
git commit -m 'xxx'
git cherry-pick --continue

## 5.完成`cherry-pick`后
git push origin master

cherry-pick 完全日志
2408261


~/Desktop/live YBLive241108 % git cherry-pick efcfb5b89a6cc45e0f5d291689d0923f7e67a230
Auto-merging YBLive.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in YBLive.xcodeproj/project.pbxproj
Auto-merging YBLive/公共方法类/YBToolClass.m
Auto-merging YBLive/直播(开始观看直播)/Agora/YBAgoraManager.m
Auto-merging YBLiveScreen/SampleHandler.m
CONFLICT (content): Merge conflict in YBLiveScreen/SampleHandler.m
error: could not apply efcfb5b8... 客户反馈功能补充以及bugfix
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".



==========================


Last login: Thu Nov  7 14:46:08 on ttys053
~ % ls
Applications            Movies              Public
Desktop             Music               Sites
Documents           OrbStack            i4Remote
Downloads           Pictures            java_error_in_idea.hprof
Library             Postman
~ % cd Desktop/live 
~/Desktop/live NuoFengTai * % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live NuoFengTai * % git add ./
~/Desktop/live NuoFengTai * % git commit -m '客户反馈功能补充以及bugfix'
[NuoFengTai efcfb5b8] 客户反馈功能补充以及bugfix
 15 files changed, 341 insertions(+), 49 deletions(-)
 create mode 100644 "YBLive/\345\212\237\350\203\275/\350\277\236\351\272\246\345\260\217\347\252\227\345\217\243/pk\344\270\273\346\222\255\344\277\241\346\201\257/PKAnchorInfoView.h"
 create mode 100644 "YBLive/\345\212\237\350\203\275/\350\277\236\351\272\246\345\260\217\347\252\227\345\217\243/pk\344\270\273\346\222\255\344\277\241\346\201\257/PKAnchorInfoView.m"
~/Desktop/live NuoFengTai % git push origin NuoFengTai
Enumerating objects: 75, done.
Counting objects: 100% (75/75), done.
Delta compression using up to 8 threads
Compressing objects: 100% (44/44), done.
Writing objects: 100% (44/44), 24.75 KiB | 4.95 MiB/s, done.
Total 44 (delta 35), reused 0 (delta 0), pack-reused 0
To http://192.168.1.55:3000/yunbao/YbLiveiOS.git
   691cca57..efcfb5b8  NuoFengTai -> NuoFengTai
~/Desktop/live NuoFengTai % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live NuoFengTai % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live NuoFengTai % git branch
  BeiJingZhao
  EnShiZhouXiHuKang
  HanXiWangLuo
  JiangSuYunDing
  LiaoNingMa
  MaLaiXiYaBw
* NuoFengTai
  ShanXiShengDu
  ShenYangWeiYouChen
  TengMeiKeJi
  TuErQiEren
  WuHanTengXin
  YBLive230621
  YBLive231114
  YBLive240201
  YBLive240820
  guohualimin
  guohualimin0801
  guohualimin0827
  henankayan
  henankayan0909
~/Desktop/live NuoFengTai % git checkout YBLive240820
Switched to branch 'YBLive240820'
~/Desktop/live YBLive240820 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive240820 % open YBLive.xcworkspace
~/Desktop/live YBLive240820 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive240820 % git checkout -b YBLive241108
Switched to a new branch 'YBLive241108'
~/Desktop/live YBLive241108 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 % git log 
commit 6e689015614832c077149c612257f811073503b1 (HEAD -> YBLive241108, origin/YBLive240820, YBLive240820)
Author: yuan <yzyuan920@163.com>
Date:   Sat Nov 2 16:15:05 2024 +0800

    客户问题同步更新ok

commit 14766bb4fbe38fc2d5d1b2ef99e0f88b870c0643
Author: yuan <yzyuan920@163.com>
Date:   Sat Oct 26 10:56:48 2024 +0800

    腾讯SDK鉴权问题处理

commit bc939d6d030ebc25923d210d8304cfba151a6eca
Author: yuan <yzyuan920@163.com>
Date:   Wed Oct 9 09:15:59 2024 +0800

    pod-pch-update

commit d345996b0106e512d20ddf80644a7e0c1f97a580
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 30 16:00:35 2024 +0800

    聊天室主播端用户列表fix

commit 7016d80ef1981ed16a1f2a7f62d194d26f112459
Author: yuan <yzyuan920@163.com>
Date:   Mon Aug 26 14:29:42 2024 +0800

    用户端观看bugfix

commit caadfa8144b55da8ab9a0c5ffb32f9a7985134e8
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 23 11:33:42 2024 +0800

    问题同步

commit adf1dbaf192d5d52e8bb2de313801a4ace58d80b
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 23 08:38:26 2024 +0800

    腾讯sdk-bugfix

commit 67dc39726ba62ebff453492afa5498e581de115a
Author: yuan <yzyuan920@163.com>
Date:   Wed Aug 21 15:28:37 2024 +0800

    开发ok

commit 5579fb010d8c72c6aeb2c48ff42d9115aa14b77f
~/Desktop/live YBLive241108 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 % open YBLive.xcworkspace
~/Desktop/live YBLive241108 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 % git log NuoFengTai
commit efcfb5b89a6cc45e0f5d291689d0923f7e67a230 (origin/NuoFengTai, NuoFengTai)
Author: yuan <yzyuan920@163.com>
Date:   Fri Nov 8 08:32:28 2024 +0800

    客户反馈功能补充以及bugfix

commit 0dbc5c5b10a9a36c786d034b491c33779d0050b6
Author: yuan <yzyuan920@163.com>
Date:   Mon Nov 4 16:22:08 2024 +0800

    sdk录屏日志

commit 691cca579a537b4d53962e2c49596273fc69e9f1
Author: yuan <yzyuan920@163.com>
Date:   Sat Nov 2 15:58:03 2024 +0800

    客户反馈fix

commit d283e648289a88b09e7ab35aca40d821dba3b0b1
Author: yuan <yzyuan920@163.com>
Date:   Fri Nov 1 10:41:36 2024 +0800

    游客报错

commit 9e0dfff0bced893d8c2c1fc2cc67d279a5547b4b
Author: yuan <yzyuan920@163.com>
Date:   Thu Oct 31 09:13:30 2024 +0800

    封包ok

commit 14766bb4fbe38fc2d5d1b2ef99e0f88b870c0643
Author: yuan <yzyuan920@163.com>
Date:   Sat Oct 26 10:56:48 2024 +0800

    腾讯SDK鉴权问题处理

commit bc939d6d030ebc25923d210d8304cfba151a6eca
Author: yuan <yzyuan920@163.com>
Date:   Wed Oct 9 09:15:59 2024 +0800

    pod-pch-update

commit d345996b0106e512d20ddf80644a7e0c1f97a580
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 30 16:00:35 2024 +0800

    聊天室主播端用户列表fix

commit 7016d80ef1981ed16a1f2a7f62d194d26f112459
Author: yuan <yzyuan920@163.com>
Date:   Mon Aug 26 14:29:42 2024 +0800

    用户端观看bugfix

commit caadfa8144b55da8ab9a0c5ffb32f9a7985134e8
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 23 11:33:42 2024 +0800

    问题同步

commit adf1dbaf192d5d52e8bb2de313801a4ace58d80b
Author: yuan <yzyuan920@163.com>
Date:   Fri Aug 23 08:38:26 2024 +0800

    腾讯sdk-bugfix

commit 67dc39726ba62ebff453492afa5498e581de115a
Author: yuan <yzyuan920@163.com>
Date:   Wed Aug 21 15:28:37 2024 +0800

    开发ok
~/Desktop/live YBLive241108 % git cherry-pick efcfb5b89a6cc45e0f5d291689d0923f7e67a230
Auto-merging YBLive.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in YBLive.xcodeproj/project.pbxproj
Auto-merging YBLive/公共方法类/YBToolClass.m
Auto-merging YBLive/直播(开始观看直播)/Agora/YBAgoraManager.m
Auto-merging YBLiveScreen/SampleHandler.m
CONFLICT (content): Merge conflict in YBLiveScreen/SampleHandler.m
error: could not apply efcfb5b8... 客户反馈功能补充以及bugfix
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
~/Desktop/live YBLive241108 * % ls
Podfile         Pods            YBLive          YBLive.xcworkspace
Podfile.lock        README.md       YBLive.xcodeproj    YBLiveScreen
~/Desktop/live YBLive241108 * % open YBLive.xcworkspace
~/Desktop/live YBLive241108 * % git add YBLiveScreen/SampleHandler.m
~/Desktop/live YBLive241108 * % git cherry-pick --continue
U   YBLive.xcodeproj/project.pbxproj
error: Committing 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.
~/Desktop/live YBLive241108 * % git add YBLiveScreen/SampleHandler.m
~/Desktop/live YBLive241108 * % git cherry-pick --continue          
U   YBLive.xcodeproj/project.pbxproj
error: Committing 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.
~/Desktop/live YBLive241108 * % git add YBLiveScreen/SampleHandler.m
~/Desktop/live YBLive241108 * % git commit -m '录屏fix'
U   YBLive.xcodeproj/project.pbxproj
error: Committing 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.
~/Desktop/live YBLive241108 * % git add ./
~/Desktop/live YBLive241108 * % git commit -m '录屏fix'
[YBLive241108 066a5893] 录屏fix
 Date: Fri Nov 8 08:32:28 2024 +0800
 15 files changed, 369 insertions(+), 70 deletions(-)
 create mode 100644 "YBLive/\345\212\237\350\203\275/\350\277\236\351\272\246\345\260\217\347\252\227\345\217\243/pk\344\270\273\346\222\255\344\277\241\346\201\257/PKAnchorInfoView.h"
 create mode 100644 "YBLive/\345\212\237\350\203\275/\350\277\236\351\272\246\345\260\217\347\252\227\345\217\243/pk\344\270\273\346\222\255\344\277\241\346\201\257/PKAnchorInfoView.m"
~/Desktop/live YBLive241108 % git cherry-pick --continue
error: no cherry-pick or revert in progress
fatal: cherry-pick failed
~/Desktop/live YBLive241108 % git cherry-pick efcfb5b89a6cc45e0f5d291689d0923f7e67a230
Auto-merging YBLive.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in YBLive.xcodeproj/project.pbxproj
Auto-merging YBLive/公共方法类/YBToolClass.m
Auto-merging YBLive/直播(开始观看直播)/Agora/YBAgoraManager.m
Auto-merging YBLiveScreen/SampleHandler.m
error: could not apply efcfb5b8... 客户反馈功能补充以及bugfix
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
~/Desktop/live YBLive241108 * % git add ./
~/Desktop/live YBLive241108 % git cherry-pick --continue                              
On branch YBLive241108
You are currently cherry-picking commit efcfb5b8.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing to commit, working tree clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'
~/Desktop/live YBLive241108 % git commit -m '合并诺丰泰'
On branch YBLive241108
You are currently cherry-picking commit efcfb5b8.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing to commit, working tree clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'
~/Desktop/live YBLive241108 % git push origin YBLive241108
Enumerating objects: 67, done.
Counting objects: 100% (67/67), done.
Delta compression using up to 8 threads
Compressing objects: 100% (36/36), done.
Writing objects: 100% (36/36), 23.93 KiB | 4.79 MiB/s, done.
Total 36 (delta 29), reused 0 (delta 0), pack-reused 0
To http://192.168.1.55:3000/yunbao/YbLiveiOS.git
 * [new branch]        YBLive241108 -> YBLive241108
~/Desktop/live YBLive241108 % 


»
新用户初次

新用户初次

配置

//新用户 初次连接仓库
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"

新工程

  1. 创建桌面文件夹 cd ……
  2. 初始化 git init
  3. 放入缓存区 git add ./
  4. 第一次提交 git commit -m first
  5. 关联仓库 git remote add origin 远程地址
  6. 强制提交 git push -f origin master

克隆某一个

cd /Users/apple/Desktop/直播
git clone -b JinShanThird 远程仓库地址

»
Other

放弃本地、拉取远程最新

git reset --hard origin/master    //origin/master替换为要拉取的远程分支名称
git add ./
git commit -m XXX
git pull

命令行执行 git branch 就进入编辑状态

解决方案:

git config --global core.pager mor

pod更新索引

更新索引、移除索引

pod repo update
pod repo update --verbose //是打印详细信息.
pod install --verbose --no-repo-update

pod repo remove trunk
rm ~/Library/Caches/CocoaPods/search_index.json

# 清楚缓存
pod cache clean --all

查询命令

grep -r --colour "tx123" /Users/yb007/Library/MobileDevice/Provisioning\ Profiles

移除

lipo -remove i386 tracking -o tracking 
lipo -remove x86_64 tracking -o tracking 

记录

git log
git log --oneline
git reflog
git reset --hard xxx

#暂存区和远程
git show xxx
git show -s

#工作区和暂存区状态
git status

#工作区和暂存区不同
git diff

#本地和远程比较
git branch -a
git diff --stat --color xxx  
确认是否已提交远程仓库

如何确定代码已经提交远程:

  1. 首先根据git status/git diff判定工作区暂存区是否同步;
  2. 利用git show -s再次判定暂存区是否提交远程;

注意:

  1. git status在主干可以确定是否是否有未提交到远程的代码;在子分支不可以区分;
  2. 不能直接使用git show -s来判断是否提交远程,因为有可能工作区的改动都没有同步到暂存区;因此需要先执行第一步.
  • 关于git status的总结:
    – 主干分支提示能够区分是否有需要提交,但未提交远程的改动
    //未提交  
    blog [master] % git status  
    On branch master  
    Your branch is ahead of 'origin/master' by 1 commit.  
    (use "git push" to publish your local commits)    
    //已提交  
    blog [master] % git status  
    On branch master  
    Your branch is up to date with 'origin/master'.  
    

    – 在子分支会提示如下信息无法区分是否有需要提交远程子分支的改动

    YBHiMo [YBLove220421] % git status  
    On branch YBLove220421
    nothing to commit, working tree clean
    
  • 关于git show -s的总结:
    未提交远程状态:(HEAD -> YBLove220421)
    YBHiMo [YBLove220421] % git show -s
    commit d3211c61865ef7437953643fe66cc86263f73dbf (HEAD -> YBLove220421)
    Author: yuan <yzyuan920@163.com>
    Date:   Fri May 27 10:40:31 2022 +0800
    
      刘海屏水印位置修复
    

    已提交远程状态:(HEAD -> YBLove220421, origin/YBLove220421)

    YBHiMo [YBLove220421] % git show -s
    commit d3211c61865ef7437953643fe66cc86263f73dbf (HEAD -> YBLove220421, origin/YBLove220421)
    Author: yuan <yzyuan920@163.com>
    Date:   Fri May 27 10:40:31 2022 +0800
    
      刘海屏水印位置修复
    

更换、检查远程链接方式

// 将https更换为ssh
git remote set-url origin git@github.com:xxx/xxx.git

// 检查
git remote -v

通信协议

拉取git仓库提示:

HTTP/2 stream 1 was not closed cleanly before end of the underlying stream.

可改为1.1

git config --global http.version HTTP/1.1

别名

[alias]
    # lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    # lg = log --color --graph --pretty=format:'%C(yellow)%h%Creset -%C(red)%d%Creset %s %Cgreen%cd (%cr) %C(blue)[by:%an]%Creset' --abbrev-commit --date=format:'%Y-%m-%d %H:%M:%S'
    # lg = log --color --graph --pretty=format:'%C(red)%d%Creset%n%C(yellow)%h%Creset \"%s\" %Cgreen%cd (%cr) %C(blue)[by:%an]%Creset' --abbrev-commit --date=format:'%Y-%m-%d %H:%M:%S'
    lg = log --color --graph --pretty=format:'%C(yellow)%h%Creset %Cgreen%cd (%cr)%Creset %C(magenta)<%an%Creset - %s %C(red)%d%Creset' --abbrev-commit --date=format:'%Y-%m-%d %H:%M:%S'