I created an account on GitHub 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, examplegit add README,git add <folder>/*, or evengit add *Then use
git commit -m "<Message>"to commit filesFinally
git push -u origin masterto push files.When you make modifications run
git statuswhich gives you the list of files modified, add them usinggit add *for everything or you can specify each file individually, thengit commit -m <message>and finally,git push -u origin masterExample – say you created a file README, running
git statusgives youRun
git add README, the files are staged for committing. Then rungit statusagain, 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 masterto push the remote branchmasterfor the repositoryorigin.The files have been pushed successfully to the remote repository.
Running a
git pull origin masterto ensure you have absorbed any upstream changesIf you do not want to merge the upstream changes with your local repository, run
git fetchto fetch the changes and thengit mergeto merge the changes.git pullis just a combination offetchandmerge.I have personally used gitimmersion – http://gitimmersion.com/ to get upto curve on git, its a step-by-step guide, if you need some documentation and help