50

How do I add files to my GitHub repository? I'm using Windows and all my project files are in one folder and I just need to upload it to my repo.

trent
  • 25,033
  • 7
  • 51
  • 90
user382738
  • 787
  • 2
  • 7
  • 12

3 Answers3

31

The general idea is to add, commit and push your files to the GitHub repo.

First you need to clone your GitHub repo.
Then, you would git add all the files from your other folder: one trick is to specify an alternate working tree when git add'ing your files.

git --work-tree=yourSrcFolder add .

(done from the root directory of your cloned Git repo, then git commit -m "a msg", and git push origin master)

That way, you keep separate your initial source folder, from your Git working tree.


Note that since early December 2012, you can create new files directly from GitHub:

Create new File

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 name yournewfile.txt.

d

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The commit and push part are actually detailed in GitHub support page http://help.github.com/create-a-repo/ – VonC Sep 26 '11 at 13:17
  • 6
    Ack, that's a bit evil for a newbie. Maybe just instead copy the files to your Git repository then git add . – Ana Betts Sep 28 '11 at 00:42
  • 2
    Good Guy VonC, Updating an answer, even though it wont probably ever be accepted. Kudos to you! – nocksock Jan 09 '13 at 16:27
  • I keep getting this fatal: This operation must be run in a work tree when doing this git --work-tree=yourSrcFolder add . – OutOFTouch Jan 25 '13 at 22:12
  • @OutOFTouch are you in the git repo? – VonC Jan 25 '13 at 22:36
  • @VonC Please see this question I just created http://stackoverflow.com/questions/14531580/how-do-i-add-files-from-another-directory-with-git – OutOFTouch Jan 25 '13 at 22:50
  • @VonC i am new in github, i had created a repository, i know how to add some text/html files, but how can i add png image file for my project.?? – mans Mar 19 '13 at 07:45
  • @mans you can add it to your local clone, and push it back to your GitHub repo. But you couldn't create/add it directly on GitHub. – VonC Mar 19 '13 at 07:48
5

You can use Git GUI on Windows, see instructions:

  1. Open the Git Gui (After installing the Git on your computer).

enter image description here

  1. Clone your repository to your local hard drive:

enter image description here

  1. After cloning, GUI opens, choose: "Rescan" for changes that you made:

enter image description here

  1. You will notice the scanned files:

enter image description here

  1. Click on "Stage Changed":

enter image description here

  1. Approve and click "Commit":

enter image description here

  1. Click on "Push":

enter image description here

  1. Click on "Push":

enter image description here

  1. Wait for the files to upload to git:

enter image description here

enter image description here

Eyal Sooliman
  • 1,876
  • 23
  • 29
2

Open github app. Then, add the Folder of files into the github repo file onto your computer (You WILL need to copy the repo onto your computer. Most repo files are located in the following directory: C:\Users\USERNAME\Documents\GitHub\REPONAME) Then, in the github app, check our your repo. You can easily commit from there.

astronautlevel
  • 478
  • 4
  • 14