0

Instead of doing git checkout branch-name from remote repo, say someone commited some files in his local branch, but forgot to push to remote repo, is there anyway we can checkout the branch from his local repo?

Renjie
  • 51
  • 1
  • 4
  • Is it not easy to ask him to push it remote repo and you pull from remote repo? – Kannaiyan Dec 02 '18 at 05:10
  • You can try solution listed here. https://stackoverflow.com/questions/5884784/how-to-pull-remote-branch-from-somebody-elses-repo – Zilu Dec 02 '18 at 05:19
  • There is only way, how to check out files from local repository. You need the local repository or copy of the local repository. You can not check out files from a standard computer, that is not a GIT server. How your GIT client should know who checked out the GIT repository and why should another client (on another computer) allow your access to its files. This would be a really big back door for espionage. Of course it is something different when you have access to repository/files via SMB or other protocol. – Julo Dec 02 '18 at 05:24

2 Answers2

0

Basically assuming that you were not prepared for this situation: You can`t

But you can prepare for this:

way 1 - with existing setup ssh on coworker machine

git clone user@coworkerip:repo/path.git

way 2 - with existing setup of git daemon on coworker machine

git clone git://coworkerip/repo.git

way 3

...

From git-clone man

Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols

So it really depends on what solution will fit your needs

dfens
  • 5,413
  • 4
  • 35
  • 50
0

You can copy the repository from their machine to your machine, then do

git remote add temp /path/to/copy/of/their/repository
git checkout temp/branch-to-checkout

Alternatively you could share their repository using NFS or Windows filesharing or something like that, and mount that share and then do the same.

Robin Green
  • 32,079
  • 16
  • 104
  • 187