Posted By: Anonymous
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 README,
git add <folder>/*, or even
git add *
git commit -m "<Message>" to commit files
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
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README
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.
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # nothing added to commit but untracked files present (use "git add" to track)
git commit -m 'Added README'
$ git commit -m 'Added README' [master 6402a2e] Added README 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README
git push -u origin master to push the remote branch
master for the repository
$ git push -u origin master Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 267 bytes, done. Total 3 (delta 1), reused 0 (delta 0) To [email protected]:xxx/xxx.git 292c57a..6402a2e master -> master Branch master set up to track remote branch master from origin.
The files have been pushed successfully to the remote repository.
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
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