Skip to content

Instantly share code, notes, and snippets.

@royswale
Forked from rotimi-best/merge.md
Created April 22, 2022 01:52
Show Gist options
  • Select an option

  • Save royswale/f639ca0a27735308745be0fa349bb988 to your computer and use it in GitHub Desktop.

Select an option

Save royswale/f639ca0a27735308745be0fa349bb988 to your computer and use it in GitHub Desktop.
How to merge one folder within two branches in git

git - How to merge one folder within two branches

In my project folder I have 2 folders client and server, I only want get the changes in my server folder from master to prod branch

  1. git checkout prod - Go to the branch with the oldest changes
  2. git merge --no-commit --no-ff master - Merge with the branch with the latest changes. Read More
  3. git reset -- client* - Unstage any changes from client folder, I only want to server folder. Read More
  4. git checkout -- client* - Remove any changes from client folder, I only want to server folder.
  5. git clean -n - View all unstaged files. Read More
  6. git clean -fd - Remove all unstaged folder, if you dont want to remove all then you should add those with git add <path> and then run this command. Read More
  7. Check if you have the required changes in the prod branch
  8. git add . && git commit -m "Merge master with prod" - Stage and commit your changes in the prod branch

Credit

The inspiration for this task came from an issue I had and this article helped think in the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment