跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[GitHub] git checkout <branch> -- path 和手动复制粘贴有区别吗?

发表于

问题背景: 假如我有分支 B 和 C 都基于 A (算是 upstream ),上游 A 在不断更新的同时,B 和 C 各自经过了很多次 commits ,两边差得很远了(并且时不时也会 merge 一下上游 A ,但是依然差得挺远,毕竟各自有各自的 feature )

但是此时突然想在 C 分支上某个目录完全使用 B 分支的版本(不能直接 merge ,因为会保留在 C 分支上的更改),这时最佳的操作是什么,能不能直接手动把 B 的文件夹复制粘贴替换过来,然后直接 git add & git commit ,这样会不会导致以后 merge A 的最新更改会有问题(期望的行为是以后 merge A 的时候,对这个目录来说,行为会跟 B 分支上的一样)。

或者用git checkout <branch> -- path,这个我实测了也问了 ChatGPT ,不会在 git 历史中留下记录,跑完之后也只是帮你把文件弄过来而已,还要自己手动 commit ,那么和手动复制粘贴有区别吗?是不是用 git checkout 才是正确的操作,以后才能正确的 merge 上游 A 。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.