zsha zsha - 4 months ago 16
Linux Question

Push a newly created file into git repository

I have created a git repository of a linux directory and pushed all files into it. I have recently moved a new file into that linux directory and now want to push this new file into its git repository. I am trying to do so by typing

git push origin master


in the command line but I am getting the errors:

fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly


Does anyone know how to push a new file into an existing git repo of the folder in which the file is present? I am new to git so would appreciate suggestions.

Answer

If your file is already in the git repo you have created, adding and committing are enough: no need to push.

myrepo      <== "I have created a git repository of a linux directory"
  .git           (the .git folder is the git repo referential)
  myNewfile <== "I have recently moved a new file into that linux directory"

http://training-course-material.com/images/thumb/8/8d/Git-commit-a2.png/250px-Git-commit-a2.png

Ie. there is no remote 'origin' to push to for a local git repo.

The chapter "Git Basics - Recording Changes to the Repository" is the good place to start.

git add myNewFile
git commit -m "Add a new file"
Comments