开发者

Git adding files to repo

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 开发者_JAVA技巧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..


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 git@github.com: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


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.


git add puts pending files to the so called git 'index' which is local.

After that you use git commit to commit (apply) things in the index.

Then use git push [remotename] [localbranch][:remotebranch] to actually push them to a remote repository.


After adding files to the stage, you need to commit them with git commit -m "comment" after git add .. Finally, to push them to a remote repository, you need to git push <remote_repo> <local_branch>.


my problem (git on macOS) was solved by using sudo git instead of just git in all add and commit commands

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜