将项目添加到git跟踪

时间:2016-05-18 08:34:51

标签: git

我有一个不是git项目的项目。我现在使用bitbucket服务把它变成了一个。

我有6个其他项目将依赖这个项目,并且想知道我可以向他们添加git源代码控制(不删除它们并从新的git clone / checkout开始)

到目前为止,我已经尝试将.git文件夹从项目的克隆复制到其他六个项目中的一个,但是当我运行“git pull”时,我会遇到如下错误:

Option Explicit
Sub grabber()
    Dim thisWb As Workbook: Set thisWb = ThisWorkbook
    Dim thisWs As Worksheet: Set thisWs = thisWb.Worksheets("dd") 'replace with relevant name
    Dim newBook As Workbook
    Dim newws As Worksheet
    Dim pathToNewWb As String
    Dim uKeys
    Dim currentPath, columnWithKey, numCols, numRows, uKey, dataStartRow, columnKeyName

    'nobody likes flickering screens
    Application.ScreenUpdating = False
    'remove any filter applied to the data
    thisWs.AutoFilterMode = False

    'get the path of the workbook folder
    currentPath = Application.ThisWorkbook.Path

    'Set the stage
    '###Hardcode###
    columnKeyName = "Facility" 'name of the column with the facility values
    dataStartRow = 4 'this is a pure guess, correct as relevenat. Use the header row index
    pathToNewWb = currentPath & "/Business Plans.xlsx" ' where to put the new excel, if you want a saveas prompt you should google "Application.FileDialog(msoFileDialogSaveAs)"
    uKeys = Range("Facilities").Value
    '###Hardcode End###
    columnWithKey = thisWs.Range(dataStartRow & ":" & dataStartRow).Find(what:=columnKeyName, LookIn:=xlValues).Column
    numCols = thisWs.UsedRange.Columns.Count

    'extract the index of the last used row in the worksheet
    numRows = thisWs.UsedRange.Rows.Count

    'create the new workbook
    Set newBook = Workbooks.Add

    'loop the facilities, and do the work
    For Each uKey In uKeys

        'Filter the keys column for a unique key
        thisWs.Range(thisWs.Cells(dataStartRow, 1), thisWs.Cells(numRows, numCols)).AutoFilter field:=columnWithKey, Criteria1:=uKey

        'copy the sheet
        thisWs.UsedRange.Copy

        'Create a new ws for the facility, and paste as values
        Set newws = newBook.Worksheets.Add
        With newws
            .Name = uKey 'I assume the name of the facility is the relevant sheet name
            .Range("A1").PasteSpecial xlPasteValues
        End With

        'remove autofilter (paranoid parrot)
        thisWs.AutoFilterMode = False

    Next uKey

    'save the new workbook
    newBook.SaveAs pathToNewWb
    newBook.Close

End Sub

有没有办法“重置”项目并拉入所有文件以开始跟踪(文件大致相同),而不删除或重新启动其他六个项目?

如果这令人困惑,我很抱歉,我不知道如何解释,如果有任何需要澄清的话请询问。

提前致谢。

1 个答案:

答案 0 :(得分:0)

原来最简单的方法是将新的repo克隆到新文件夹中,将其他文件夹内容复制到该文件夹​​中,然后将整个文件夹复制回原始文件的顶部(包括新的.git信息)