1

I have installed Git for Windows. There is both a graphical shell and a shell with CUI. I have created a repository using the graphical shell :

enter image description here

How do I push the code to the Git repository ? In the repository URL, I see this push URL :

git remote add origin https://github.com/suhailgupta03/Nappster.git
git push -u origin master

Can anyone please tell, how do I use this URL to push the code ? Like I have a directory named x and I want to upload the code in that directory to the repository named Nappster (the url for which I have give above.)

saplingPro
  • 20,769
  • 53
  • 137
  • 195
  • I think I understand the question, but is all your code in a directory named 'x' not in the directory 'Nappster' shown in your screenshot, but you want that code in x to be part for the Nappster git repo? – Adam Elsodaney Jan 01 '13 at 17:18
  • @Adam-E Currently the code in the directory named `x` isn't isn't inside the directory `nappster`. I want to put the code/directory to the repository `nappster` – saplingPro Jan 01 '13 at 17:23

2 Answers2

1

If you are suhailgupta03 on GitHub, a simple click on the "pushing to GitHub" should be enough.

If not, that button would push to a newly create GitHub 'Napster' repo owithin your GitHub account.
Or you can define a primary remote repo, as I illustrate in "Use GitHub for Windows for both BitBucket and Github".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Shall I place the directory that contains the code, under the nappster directory ? Also when I click `publish` [here](http://i48.tinypic.com/if6beb.jpg) I get to see [this](http://i46.tinypic.com/mafr5j.jpg) – saplingPro Jan 01 '13 at 17:33
  • @saplingPro The name of the parent directory doesn't matter, as long as it contains your git repo (and it `.git` directory). Note that you do have to add and commit files first, before pushing anything. – VonC Jan 01 '13 at 17:52
  • can you explain what actually, does commit mean ? And how do I commit changes ? [Files](http://i46.tinypic.com/34yagip.jpg) – saplingPro Jan 01 '13 at 18:06
  • @saplingPro you can see all the basic concepts here: http://gitimmersion.com/ , as well as http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository – VonC Jan 01 '13 at 18:12
1

There two things you can do, you can either

a. Copy the code in directory 'x' to 'Nappster' and run the following commands from the Git CLI

cd /w/GitHub/Nappster
git add .
git remote add origin https://github.com/suhailgupta03/Nappster.git
git push -u origin master

or b. Initialise 'x' as the git repo

cd path/to/x
git init
git add .
git remote add origin https://github.com/suhailgupta03/Nappster.git
git push -u origin master

You can call your origin whatever you like, eg. github

git remote add github https://github.com/suhailgupta03/Nappster.git
git push -u github master

Every time you do a push from thereon, should drop the -u flag so it's just

git push github master

Word of warning, if you have a file that contains database connection info for example, you need to add that file name eg db_credentials.php to the .gitignore file and create another file eg. db_credentials.php.dist without the sensitive info

Adam Elsodaney
  • 7,722
  • 6
  • 39
  • 65
  • can I copy the folder `x` inside nappster? [(which is)](http://i50.tinypic.com/aaawdj.jpg) – saplingPro Jan 01 '13 at 17:55
  • I am having some problem while pushing the code. Can we please discuss here @ http://chat.stackoverflow.com/rooms/21997/discussion-between-adam-e-and-saplingpro – saplingPro Jan 01 '13 at 18:23
  • You need to commit the files first before pushing (See chat log) – Adam Elsodaney Jan 01 '13 at 21:17
  • ok. what does commit mean here ? Though I have successfully pushed the code,I do not know what does commit mean – saplingPro Jan 02 '13 at 04:44
  • @saplingPro take a look at the gitref page about the basic git workflow here: http://gitref.org/basic/ the commit is one of the most important parts of git. the idea is to code, add the code to the staging area, then commit the code to the repository. then after as many or few commits as you desire, you can push your repository to a remote location. – xero Jan 03 '13 at 16:39