Reputation: 3850
Here is what I did:
Here is my problem:
Here is what I want to do:
How can I make files other than "my_dir/" in "my_branch" to be same with "master", while keep files under "my_dir/" to be same with "my_branch"? One possible way is that I checkout "master", copy all files under directories like "somebody1/", "somebody2/" etc., to some place else, then checkout "my_branch", then copy those files back to my working directory and then commit.
But How can I do it with Git command? Does Git provide such util?
Upvotes: 2
Views: 83
Reputation: 22067
From your branch, assuming your remote is named origin
git fetch
git restore --source=origin/master .
git restore --source=my_branch my_dir/
git commit -am "Resynced everything but my_dir with master"
Edit after comments : in case you're running a version of git prior to 2.20.1 (thanks Vespene Gas for the reminder), you won't be able to use git restore
. The alternative is the older command git checkout <ref> [-- <path> [<other_path>]]
. Then again, as Matt rightfully pointed out, you might need to get rid of unwanted files in your repo after the operation with something like git clean
)
Upvotes: 2