Home > Blockchain >  Sync Git Branch to a specific folder
Sync Git Branch to a specific folder

Time:01-21

Suppose I have a git repo named waterkingdom It has lot of branches. We will be working with a specific branch called wave-pool.

wave-pool branch has files & folders such as

cost.txt
ride.txt
rules.txt
code/
code/ride.py
code/boom/crash.py

We have another folder which is not a part of the repo named wave-pool-boom

How can I only sync the branch wave-pool from waterkingdom repo to the folder called wave-pool-boom after the commit without knowing the latest commit hash? Everything is locally on Linux.

CodePudding user response:

How can I only sync the branch wave-pool from waterkingdom repo to the folder called wave-pool-boom after the commit without knowing the latest commit hash??

Everything is locally on LINUX.

Pushing branches from one repo to another is easily done in git, and makes a lot of sense the more you work with git.

  1. Clone waterkingdom into a new directory
git clone --single-branch -b wave-pool /path/to/waterkingdom ~/projects/waterkingdom
cd ~/projects/waterkingdom
  1. Setup a new remote
git remote add r-wave-pool-boom /path/to/wave-pool-boom
  1. Push the branch to the remote (but do not change its tracked remote branch)
git push r-wave-pool-boom wave-pool
  1. Remove the remote (optional)
git remote remove r-wave-pool-boom

Tools to help you further your Git knowledge

  • git branch -avv

Gives a listing of all branches and what remote branch (if any) they track, what the latest commit hash/message is, and the state (behind, ahead) of each branch.

  • git remote -v

Give a listing of all the remotes (if any) and their URL's configured for your local repo.

Further comments

Why "without knowing the latest commit hash"? The latest commit hash is always HEAD or <branch-name> or refs/remotes/origin/<branch-name>.

  • Related