Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Upload Files on GitHub

I have recently downloaded GitHub and created a repository on it. I am trying to upload an Objective C project in it. How do I go about doing this?

like image 353
Cai Gengyang Avatar asked Mar 06 '12 04:03

Cai Gengyang


People also ask

How do I add files to a git repository?

To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.

How do I upload folders and files to GitHub repository?

Clone the repository locally. Make the changes to the local version. Commit the changes locally. Push the changes back up to the GitHub repository.


Video Answer


1 Answers

I didn't find the above answers sufficiently explicit, and it took me some time to figure it out for myself. The most useful page I found was: http://www.lockergnome.com/web/2011/12/13/how-to-use-github-to-contribute-to-open-source-projects/

I'm on a Unix box, using the command line. I expect this will all work on a Mac command line. (Mac or Window GUI looks to be available at desktop.github.com but I haven't tested this, and don't know how transferable this will be to the GUI.)

Step 1: Create a Github account Step 2: Create a new repository, typically with a README and LICENCE file created in the process. Step 3: Install "git" software. (Links in answers above and online help at github should suffice to do these steps, so I don't provide detailed instructions.) Step 4: Tell git who you are:

git config --global user.name "<NAME>" git config --global user.email "<email>" 

I think the e-mail must be one of the addresses you have associated with the github account. I used the same name as I used in github, but I think (not sure) that this is not required. Optionally you can add caching of credentials, so you don't need to type in your github account name and password so often. https://help.github.com/articles/caching-your-github-password-in-git/

Create and navigate to some top level working directory:

mkdir <working> cd <working> 

Import the nearly empty repository from github:

git clone https://github.com/<user>/<repository> 

This might ask for credentials (if github repository is not 'public'.) Move to directory, and see what we've done:

cd <repository> ls -a git remote -v 

(The 'ls' and 'git remote' commands are optional, they just show you stuff) Copy the 10000 files and millions of lines of code that you want to put in the repository:

cp -R <path>/src . git status -s 

(assuming everything you want is under a directory named "src".) (The second command again is optional and just shows you stuff)

Add all the files you just copied to git, and optionally admire the the results:

git add src git status -s 

Commit all the changes:

git commit -m "<commit comment>" 

Push the changes

git push origin master 

"Origin" is an alias for your github repository which was automatically set up by the "git clone" command. "master" is the branch you are pushing to. Go look at github in your browser and you should see all the files have been added.

Optionally remove the directory you did all this in, to reclaim disk space:

cd .. rm -r <working> 
like image 86
Michael Woodhams Avatar answered Sep 28 '22 03:09

Michael Woodhams