How to use GITHUB command to migrate specific file from branch A to branch B remotely?

Greetings, I have two branch, one for DEV and another named UAT. Currently I have command to add files after clone it (please see Part A). But there are 5TB files in the branch so I can’t do that for update and/or further deployment.

Therefore, I would like to migrate specific file from DEV to UAT (e.g. test.txt) without clone all files (or download) again after file updated. May I ask your help? Thanks a lot.

Part A) Command to create files but can’t handle update case for specific file:

git clone https://github.com/ABCTester/somewhere-test.git/
git checkout DEV
git add test.txt
git commit -m “job#”
git push origin DEV

git checkout UAT
git checkout DEV test.txt
git add test.txt
git commit -m “Job#”
git push origin UAT

Consider:

Imagine you want:

Just cheat:
There’s a raw link: https://raw.githubusercontent.com/actions/checkout/Update-description/README.md

Download that to your repo on the branch you like.

git add -u
git commit -m 'File retrieved from https://raw.githubusercontent.com/actions/checkout/Update-description/README.md'
(you could list the sha of the commit instead, but…)

thanks for reply. I tried to use “checkout” (just like my test code) but seems we still have to clone the entire workspace for it. If possible, I don’t want to download any files (as total 5 TB) and I just want to migrate one file from branch A to B (e.g. UAT to PRODUCTION, vice versa from ROLLBACK branch to PRODUCTION branch) , I would like to keep processing time as short as possible.

In parallel, I’m trying git clone --no-checkout and GIT show command. But not sure how to upload it to Branch B for singe file only, and better approach I want to do is to migrate the file without file download. Please help if anyone has idea on it.

In addition, do you mean git-add - u can work with update case without delete any files? Let me check and reply later.

Try using the GitHub API: Create or update file contents

That said, if your repository is that huge you might want to consider ways to restructure it.

You need --single-branch in your clone command

Thanks . I will try --single-branch first as I got SSL error for GITHUB API and not yet identify the root cause.