I have two projects. One is the "official" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed.
How do I commit only these files?
Try git commit -m 'my notes' path/to/my/file. ext , or if you want to be more explicit, git commit -m 'my notes' -- path/to/my/file.
Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.
1 Answer. Then you can git commit a single file directory.
I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches.
You commit only the changed files by:
git commit [some files]
Or if you are sure that you have a clean staging area you can
git add [some files] # add [some files] to staging area git add [some more files] # add [some more files] to staging area git commit # commit [some files] and [some more files]
If you want to make that commit available on both branches you do
git stash # remove all changes from HEAD and save them somewhere else git checkout <other-project> # change branches git cherry-pick <commit-id> # pick a commit from ANY branch and apply it to the current git checkout <first-project> # change to the other branch git stash pop # restore all changes again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With