如何列出在两个分支之间更改的文件夹中的文件?

时间:2015-10-07 23:20:10

标签: git branch

例如,我有一个名为myfolder的文件夹;如何列出myfolder中两个分支(branchAbranchB之间发生变化的文件?)

2 个答案:

答案 0 :(得分:2)

我建议通读

git help diff

您正在寻找的特定命令是:

git diff --name-only $branch1 $branch2 -- $path_to_folder_or_file

答案 1 :(得分:-2)

您可以按如下方式比较两次提交之间的差异:

public static void SaveVideoToGallery(Activity activity, String filePath) {

    // get filename from path
    int idx = filePath.LastIndexOf("/") + 1;
    String name = filePath.Substring(idx, filePath.Length - idx);

    // set in/out files
    File inFile = new File(filePath);
    File outDir = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMovies);
    File outFile = new File(outDir, name);

    // Make sure the Pictures directory exists.
    outDir.Mkdirs();

    // save the file to disc
    InputStream iStream = new FileInputStream(inFile);
    OutputStream oStream = new FileOutputStream(outFile);

    int bytes = 0;
    byte[] data = new byte[1024];
    while ((bytes = iStream.Read(data)) != -1) 
    { 
        oStream.Write (data, 0, bytes);
    }

    iStream.Close();
    oStream.Close();

    // Tell the media scanner about the new file so that it is
    // immediately available to the user.
    MediaScannerConnection.ScanFile(
        activity.ApplicationContext,
        new String[] { outFile.ToString() }, 
        null,
        null);
}

您将获得回购邮件中所有提交的列表: 例如..

git log

现在进行比较:

commit 8781017d5d7e507511fd1631b9263620671407ea
Author: DavidANegrete <davidnegrete@g.harvard.edu>
Date:   Wed Oct 7 14:18:41 2015 -0600

    complete the method to seach

commit 10eab44a41a4f4141b7cce80ffcaa7a676297bcb
Author: DavidANegrete <davidnegrete@g.harvard.edu>
Date:   Sat Oct 3 18:57:20 2015 -0600