【问题标题】:How to run a specific version of the app from Git via Android Studio?如何通过 Android Studio 从 Git 运行特定版本的应用程序?
【发布时间】:2021-05-11 01:30:53
【问题描述】:

我使用 git 作为我的 VCS 并每隔几天提交一次我的代码。然而,一个 bug 悄悄出现了,我需要检查之前提交的应用程序版本是否也有这个 bug。

如何在不丢失我尚未提交的本地更改的情况下将当前代码库切换到不同的 git 版本? Android Studio 中有没有办法直接从 git 构建和测试特定版本?

【问题讨论】:

    标签: android git android-studio version-control


    【解决方案1】:

    有些人可能会建议git stashgit stash pop/apply

    git stash
    git checkout <commit>
    # build and test
    git checkout <previous-branch>
    git stash pop
    # or git stash apply
    

    但我推荐git worktree。假设版本为abc123

    git worktree add /path/to/foo abc123
    cd /path/to/foo
    # build and test
    

    abc123 的文件夹和文件被检出到/path/to/foo。它不影响当前的主工作树。在/path/to/foo 中完成工作后,您可以通过以下方式删除额外的工作树:

    git worktree remove /path/to/foo
    # or
    rm -rf /path/to/foo
    git worktree prune
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 2018-10-31
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      相关资源
      最近更新 更多