How to check out file in Git?

8.4k views Asked by At

I just started using github.com and my friend and I are working on a project. How can I pull parts of the project but check out certain files I'm working on so he doesn't work on them. He can still download the files but he won't be able to open or edit them until I upload them back and give permission?

3

There are 3 answers

0
VonC On BEST ANSWER

If you really want to work that way (i.e: lock files, or at least control when your friend will modify your repo), you can ask your friend to fork your repo.

That way, he/she:

  • will have his/her own copy of said repo
  • will work on any file
  • will rebase first with branches fetched from your repo (added as a remote on his/her fork, as described in GitHub: working with remotes)
  • will make pull request, allowing to decide what to include and when.
2
Elbert Alias On

I suppose you mean lock a file when you edit it. Git won't let you do this and it's not something you need to worry about. Instead, you can both work on the same file and then merge your changes later.

0
D Miller On

Historically version control systems provide a checkin/checkout feature. When you do a checkout, you reserve the artifact. If another person also has the same file checked out, then you get an error when trying to checkin the artifact. Not sure creating another fork is really the equivale