MeltingDog
MeltingDog

Reputation: 15404

Git: How do I checkout/push only my files?

I am new to Git and am really struggling to get my head 'round how it works.

Here's the situation: I worked on a simple .css change, and pushed it to Github. No dramas there. A few days later I realised I had made a mistake in the CSS file and so checked out that branch to fix my mistake. I fix the code and do a git status just to check everything, but I see about 100 other files appear in my 'Changes to be committed list'.

None of these files have anything to do with what I've been working on, so I figure someone might have added to my branch on GitHub. I go to GitHub and check but on my branch's page but I only see my 1 file and 1 commit. I don't know where these other files have come from, but obviously it was probably when I checked out.

Would anyone know what's happened here?

Also, how do I push just my files? I don't want to push a whole heap of others.

Upvotes: 0

Views: 100

Answers (3)

Duyet Nguyen
Duyet Nguyen

Reputation: 543

git add file1.css file2.css file3.css

git commit -m "msg"

git push

Upvotes: 1

aikramer2
aikramer2

Reputation: 1353

If you had other files on your local directory, you likely did a git add .. In general, add the specific file you want to track in git. git reset will undo all staged changes. Then commit the change to the file you want to change, and push.

Upvotes: 2

Raghu
Raghu

Reputation: 470

If you want to commit only your file use the command

git commit [some files]

I assume you have not added any new files, so 'add' command is not necessary.

Please refer this answer for detailed explanation

Upvotes: 1

Related Questions