Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git adding files to repo

Tags:

git

github

I followed basic Git tutorial and added README file, which worked. Then I copied my project files to the same folder and tried to add them to repository by running

git add --all git ci 'test' (my alias for commit) git push origin master 

and nothing got pushed.

What are the commands I should run to push my files to the remote repository (master)?

I tried to commit changes and run status but it says 'nothing to commit'. It does not recognize, that I copied lots of new files to that folder..

OK, so I type: git add . (get no response from console) then type to commit, and says no changes..

like image 610
Stewie Griffin Avatar asked Aug 13 '11 00:08

Stewie Griffin


People also ask

How do I add a file to GitHub repository terminal?

add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder: git add . Then type: git commit -m "adding files" . And then: git push -u origin master .


2 Answers

This is actually a multi-step process. First you'll need to add all your files to the current stage:

git add . 

You can verify that your files will be added when you commit by checking the status of the current stage:

git status 

The console should display a message that lists all of the files that are currently staged, like this:

# On branch master # # Initial commit # # Changes to be committed: #   (use "git rm --cached <file>..." to unstage) # #   new file:   README #   new file:   src/somefile.js # 

If it all looks good then you're ready to commit. Note that the commit action only commits to your local repository.

git commit -m "some message goes here" 

If you haven't connected your local repository to a remote one yet, you'll have to do that now. Assuming your remote repository is hosted on GitHub and named "Some-Awesome-Project", your command is going to look something like this:

git remote add origin [email protected]:username/Some-Awesome-Project 

It's a bit confusing, but by convention we refer to the remote repository as 'origin' and the initial local repository as 'master'. When you're ready to push your commits to the remote repository (origin), you'll need to use the 'push' command:

git push origin master 

For more information check out the tutorial on GitHub: http://learn.github.com/p/intro.html

like image 144
ninjascript Avatar answered Sep 21 '22 09:09

ninjascript


I had an issue with connected repository. What's how I fixed:

I deleted manually .git folder under my project folder, run git init and then it all worked.

like image 37
Stewie Griffin Avatar answered Sep 18 '22 09:09

Stewie Griffin