Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upload fresh code at github?

Tags:

git

github

I have a directory with all my coding projects.

I want to upload (correct terminology?) it to GitHub using the command line.

I have already looked at Old question.

I know how to clone an existing project, and how to push it after making any changes.

But in this case, I want to make a new project and add files to that.

How can I accomplish this using the command line?

like image 324
Lazer Avatar asked May 19 '10 15:05

Lazer


4 Answers

git init
git add .
git commit -m "Initial commit"

After this, make a new GitHub repository and follow on-screen instructions.

like image 191
Veeti Avatar answered Oct 28 '22 06:10

Veeti


If you haven't already created the project in Github, do so on that site. If memory serves, they display a page that tells you exactly how to get your existing code into your new repository. At the risk of oversimplification, though, you'd follow Veeti's instructions, then:

git remote add [name to use for remote] [private URI] # associate your local repository to the remote
git push [name of remote] master # push your repository to the remote
like image 28
Rob Wilkerson Avatar answered Oct 28 '22 06:10

Rob Wilkerson


Just to add on to the other answers, before i knew my way around git, i was looking for some way to upload existing code to a new github (or other git) repo. Here's the brief that would save time for newbs:-

Assuming you have your NEW empty github or other git repo ready:-

cd "/your/repo/dir"
git clone https://github.com/user_AKA_you/repoName # (creates /your/repo/dir/repoName)
cp "/all/your/existing/code/*" "/your/repo/dir/repoName/"
git add -A
git commit -m "initial commit"
git push origin master

Alternatively if you have an existing local git repo

cd "/your/repo/dir/repoName"
#add your remote github or other git repo
git remote set-url origin https://github.com/user_AKA_you/your_repoName
git commit -m "new origin commit"
git push origin master
like image 22
mrmoje Avatar answered Oct 28 '22 08:10

mrmoje


You can create GitHub repositories via the command line using their Repositories API (http://develop.github.com/p/repo.html)

Check Creating github repositories with command line | Do it yourself Android for example usage.

like image 6
ddewaele Avatar answered Oct 28 '22 06:10

ddewaele