How to push a single file in a subdirectory to Github (not master)

moon star picture moon star · Nov 20, 2012 · Viewed 174.7k times · Source

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?

Answer

krilovich picture krilovich · Nov 20, 2012

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