简体   繁体   中英

Git: copy a file from one repository to another (unrelated) repository

I have 2 git repositories

  • Rep1 is on my local computer. It contains a file called file.txt which is tracked.

  • Rep2 is in a cluster folder.

Both folders are "local" - ie they do not have origins to push and pull to.

I would like to copy file.txt from Rep1 to Rep2. Can I just:

  • Use scp from Rep1 to Rep2
  • Git add file.txt in Rep2

These repositories are not related so I literally only want to copy a file from one to the other. Is that possible?

If you want to copy file from a directory1 to a directory2, it has nothing to do with git, and especially nothing to do with the "from" repository.

Just copy the file normally (with scp for instance) then track it in the other repository using git add

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM