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.
When adding a directory to github check that the directory does not contain a .git file using "ls -a" if it does remove it. .git files in a directory will cause problems when you are trying to add a that directory in git
Check my answer here : https://stackoverflow.com/a/50039345/2647919
"OR, even better just the ol' "drag and drop" the folder, onto your repository opened in git browser.
Open your repository in the web portal , you will see the listing of all your files. If you have just recently created the repo, and initiated with a README, you will only see the README listing.
Open your folder which you want to upload. drag and drop on the listing in browser. See the image here."
Simple solution:
git init
git add =A
git commit -m "your commit"
git push -u origin master
if you want add folder to existing repo ..then add folder to local project code
git rm --cached ./folderName
git add ./folderName
after that
git status
git commit -m "your commit"
git push -u origin master
I'm using VS SSDT on Windows. I started a project and set up local version control. I later installed git and and created a Github repo. Once I had my repo on Github I grabbed the URL and put that into VS when it asked me for the URL when I hit the "publish to Github" button.
For Linux and MacOS users :
Note that since early December 2012, you can create new files directly from GitHub:
ProTip™: You can pre-fill the filename field using just the URL.
Typing?filename=yournewfile.txt
at the end of the URL will pre-fill the filename field with the nameyournewfile.txt
.
You need to checkout the repository onto your local machine. Then you can change that folder on your local machine.
git commit -am "added files"
That command will commit all files to the repo.
git push origin master
that will push all changes in your master branch (which I assume is the one you're using) to the remote repository origin (in this case github)
If you want to add an empty folder you can add a '.keep' file in your folder.
This is because git does not care about folders.
Source: Stackoverflow.com