0

I have a Github repository and I'm trying to pull the repository (it's already cloned) to my home machine but for some reason it does not pull all the folders from the Github repository.

I tried both the fetch and pull but the result is same.

When I do the pull, under Update result, I get a DIRTYTREE error on a .pyc file.

This is a simple python project.

and my github link is https://github.com/PREM1980/Test/tree/master/ecomstore/ecomstore/templates

and the folder I'm trying to retrieve is templates.

7
  • This looks like a pretty good post regarding your issue: stackoverflow.com/questions/9855946/… Commented May 2, 2013 at 0:27
  • Would you mind showing the complete error? Commented May 2, 2013 at 0:27
  • That's not a question. Commented May 2, 2013 at 0:27
  • First, the link you showed is not a repo, it's a directory in the middle of a repo. And there are no .pyc files inside that templates or its subdirectories. I'm willing to bet you're actually trying to pull the parent directory, and the error is one of those .pyc files checked in there, although of course it's hard to be sure with incomplete and incorrect information. Commented May 2, 2013 at 0:40
  • yes, you are correct..ecomstore is the actual project I want to pull that project in the repository? Is it good to have one repository for one project?? Commented May 2, 2013 at 0:43

1 Answer 1

1

When I do the pull, under Update result, I get a DIRTYTREE error on a .pyc file..

There are no .pyc files under the path you gave us. But I'm willing to bet you're actually pulling the entire repo, not some random subdirectory underneath it, despite what you say in the question, because that repo does have .pyc files in it.

The problem is that any time you import a .py file, it can rewrite the .pyc file, causing you to get ahead of the master. Once you get ahead of the master in some way that isn't tracked, you will need to merge, rebase, or otherwise clean things up if you want to pull or push. A good git tutorial will explain this.

But the right way to solve this is to just not check in .pyc files. There is almost never a good reason to do so, and plenty of good reasons not to.

There's a great collection of .gitignore files at https://github.com/github/gitignore (and the appropriate one will even be applied automatically if you use the Github website or client to create a new project). You'll notice that the Python one starts with .py[cod]. You should do the same.

If you don't want to use a .gitignore, this just means you can't use the -a flag anywhere; you'll have to manually manage which files are and are not checked in, and don't manually add the .pyc files.

If you have a good reason to check in the .pyc files, you probably want to prevent Python from updating them except when you choose to do so explicitly. In other words, during normal development, always run with the -B flag or PYTHONDONTWRITEBYTECODE env variable; then, when you're ready to push, delete the .pyc files and make Python generate them manually.

If you actually want to manage your .pyc files the way you're doing, and it's not an accident, and you just want to know how to manually merge your way out of an unexpected conflict: you do it the same way as with any other conflicting files. For example, stash, pull, unstash will give you the chance to manually pick one .pyc version or the other without screwing up anything else. (You have to know which one you want… but if you don't know that, you don't have a good reason to be managing your .pyc files this way.)

Sign up to request clarification or add additional context in comments.

5 Comments

Is there a way just to pull the ecomstore folder alone?
@user1050619: If you're asking whether you can only clone ecomstore in the first place, rather than the whole repo: You probably shouldn't do that, but the consequences aren't horrible, and it isn't too hard. "sparse clone" functionality is built into git nowadays. (If you have an older version and can't upgrade, you can find various scripts people have come up with if you google for "git sparse clone".) But first, consider whether you really want this. Why not just make ecomstore its own repo? (If you also want it to appear in the larger repo, that's what submodules are for.)
@user1050619: If, on the other hand, you're asking whether you can pull just ecomstore into a clone of the entire repo… that's a much, much worse idea. The problem is that your repo tracks the upstream repo atomically—there's a revision that your entire repo is synced to, not a revision that each file is synced to. There are tricks that can make this work, but… really, why not just sparse-clone a separate repo (or convert your existing one)?
@user1050619: If you decide you want to do a sparse clone, see this blog post, which explains it all much more simply than the official docs.
@abarnert..I will have a separate repository for each project..Just want to check on the folders and how it works....THanks once agains

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.