Django / Git:为什么仍然要__pycache __?

时间:2019-12-04 08:57:45

标签: django git gitignore

我尝试使用Django和Git进行工作。 我遇到了许多冲突问题,并试图更好地理解Git和Django,以实现一种工作流,该工作流应避免可能的冲突(即使并非总是可能的)

我在Gitlab远程存储库中有origin / master分支(= dev分支),在本地存储库中有相应的master。

我定义了具有不同问题的待办事项。

我决定处理问题#1,因此我在本地master中拉出了origin / master的最新信息,并创建了本地分支名称Feature / 1。

我在这个Feature / 1分支上工作,昨天提交。

我还没有完成有关此问题的工作,但是当我完成工作后,为了完成工作流程,我将在Gitlab上推送此功能/ 1,并提出合并请求以与原点/事项合并。之后,我拉出origin / master,取消本地的feature / 1分支,并创建一个新的feature / 2分支。

今天早上,我结帐了我的本地主服务器,以验证我是否仍与原始服务器/主服务器保持最新,情况是这样,除了git提到已修改了3个文件:

On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    myapp/__pycache__/settings.cpython-37.pyc
        deleted:    myapp/__pycache__/urls.cpython-37.pyc
        deleted:    myapp/__pycache__/views.cpython-37.pyc

我了解pychache文件是预编译的代码,可以加快代码执行速度。

但是我不明白:我还没有在本地主机上工作,在根目录下的.gitignore文件存储中提到了 pycache

那么为什么提到此文件?如果我提交了,我将在与原始/主提交之前进行一次提交,并且必须进行推送吗?

我的工作流程有什么问题?

2 个答案:

答案 0 :(得分:1)

这些文件存在于存储库中(可能来自您没有master的时间或分支),但已在本地框中删除。

您可能要进行一次提交,以从git ls-files '*.pyc' | xargs git rm -f 或类似的东西中清除它们(全部),用类似的话说

private string GetBodyFromRequest(HttpActionExecutedContext context)
        {
            string data;
            using (var stream = context.Request.Content.ReadAsStreamAsync().Result)
            {
                if (stream.CanSeek)
                {
                    stream.Position = 0;
                }
                data = context.Request.Content.ReadAsStringAsync().Result;
            }
            return data;
        }

然后提交更改。

答案 1 :(得分:0)

.gitignore

void BreadthFirstSearch(GraphType<string> graph, string startVertex, string endVertex)
    // Assumes VertexType is a type for which the “==“ and “<<“
    // operators are defined.
{
    QueType<string> queue;
    QueType<string> vertexQ;
    bool found = false;
    string vertex;
    string item;
    graph.ClearMarks();
    queue.Enqueue(startVertex);
    do
    {
        queue.Dequeue(vertex);
        if (vertex == endVertex)
        {
            cout << vertex;
            found = true;
        }
        else
        {
            if (!graph.IsMarked(vertex))
            {
                graph.MarkVertex(vertex);
                cout << vertex << " ";
                graph.GetToVertices(vertex, vertexQ);
                while (!vertexQ.IsEmpty())
                {
                    vertexQ.Dequeue(item);
                    if (!graph.IsMarked(item))
                        queue.Enqueue(item);
                }
            }
        }
    } while (!queue.IsEmpty() && !found);
    if (!found)
        cout << "Path not found." << endl;
}