简体   繁体   English

GIT部分更新本地文件

[英]GIT Partial Update local files

I never used GIT before, so, I'm a newbie. 我以前从未使用过GIT,所以我是新手。 And I have a complex task for git. 我对git有一个复杂的任务。 For example, I have a directory on server (local), where I installed some app from nightly repository by apt-get install. 例如,我在服务器(本地)上有一个目录,该目录通过apt-get install从每晚存储库安装了一些应用程序。 I made some changes in app code, in a different files and directories. 我在不同的文件和目录中的应用程序代码中进行了一些更改。 After that I committed this new custom version on bitbucket. 之后,我在bitbucket上提交了这个新的自定义版本。 This is a second point of my tasks. 这是我任务的第二点。 And the third step: I updated current app through apt-get update/ apt-get upgrade app. 第三步:我通过apt-get update / apt-get upgrade应用程序更新了当前应用程序。 So, first of all, how I can change my local current app with remote custom app? 因此,首先,如何使用远程自定义应用程序更改本地当前应用程序? When I try to use "git pull repository", it says 'Already up-to-date'. 当我尝试使用“ git pull仓库”时,它说“已经是最新的”。 And the second question: when I updated current app with apt-get upgrade, how I can pull only custom files from bitbucket? 第二个问题:当我使用apt-get upgrade更新当前应用程序时,如何仅从bitbucket中提取自定义文件?

For example, after app installation I have a next structure 例如,安装应用程序后,我有一个下一个结构

Folder1 / File  version A
Folder2 / File1 version A
          File2 version A

After my custom updates and commit to bitbucket: 在我自定义更新并提交到bitbucket之后:

Folder1 / File  version B
Folder2 / File1 version A
          File2 version B

After apt-get upgrade: apt-get升级后:

Folder1 / File  version C
Folder2 / File1 version C
          File2 version C

Now I need next structure in local: 现在我需要本地的下一个结构:

Folder1 / File  version B
Folder2 / File1 version C
          File2 version B

How can I do this? 我怎样才能做到这一点?

You can discard changes to your working copy state by using git checkout -- path/to/file 您可以使用git checkout -- path/to/file放弃对工作副本状态的更改git checkout -- path/to/file

You should be able to get the state you want by running 您应该能够通过运行获得所需的状态

git checkout -- Folder1/File
git checkout -- Folder2/File2

which is effectively resetting the state of the files to the one you have in version control. 有效地将文件状态重置为您在版本控制中拥有的文件状态。 Note that this may lead to the app breaking, since not only your changes are applied, but also the changes done in the update are reversed! 请注意,这不仅可能导致应用中断,因为不仅会应用您的更改,而且更新中所做的更改也会被撤消!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM