How do I add files and folders into GitHub repos?


I created an account on GitHub — I’m new on it — and I’m facing a problem with adding files. I have added readme.txt. Also, I have 3 other PHP files and a folder including images.

How do I add the files and folder? I tried it with git pull because git push origin -u master showed me an error.


You can add files using git add, example git add READMEgit add <folder>/*, or even git add *

Then use git commit -m "<Message>" to commit files

Finally git push -u origin master to push files.

When you make modifications run git status which gives you the list of files modified, add them using git add * for everything or you can specify each file individually, then git commit -m <message> and finally, git push -u origin master

Example – say you created a file README, running git status gives you

Run git add README, the files are staged for committing. Then run git status again, it should give you – the files have been added and ready for committing.

Then run git commit -m 'Added README'

Finally, git push -u origin master to push the remote branch master for the repository origin.

The files have been pushed successfully to the remote repository.

Running a git pull origin master to ensure you have absorbed any upstream changes

If you do not want to merge the upstream changes with your local repository, run git fetch to fetch the changes and then git merge to merge the changes. git pull is just a combination of fetch and merge.

Leave a Reply