I have changed a single file in a subdirectory of my repository and I want to push just that file to Github.
I've made a small change to one file, and I don't want to re-upload the entire repository.
It seems like all of the instructions that I've seen so far require me to merge locally with the master and then push my local master to the remote origin.
How can I push just that one file?
In order to push a Git branch to remote, you need to execute the “git push” command and specify the remote as well as the branch name to be pushed. If you are not already on the branch that you want to push, you can execute the “git checkout” command to switch to your branch.
To find it go to Settings > Branches > Branch Protection Rules and click 'Add Rule'. Then, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging.
initialize a new repo to serve as the child repo. move everything from the subdirectory of the parent repo work tree to the child repo work tree. commit the child repo. replace the subdirectory in the parent repo with a submodule reference.
When you do a push, git only takes the changes that you have committed.
Remember when you do a git status
it shows you the files you changed since the last push?
Once you commit those changes and do a push they are the only files that get pushed so you don't have to worry about thinking that the entire master gets pushed because in reality it does not.
How to push a single file:
git commit yourfile.js git status git push origin master
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