After a Git push, remote repo shows files as deleted

前端 未结 3 781
無奈伤痛
無奈伤痛 2020-12-10 21:30

I cannot find any of the files on my remote repo.

  1. Created a Git repo on shared hosting (site5) as described by their tutorial
  2. init\'d it and added a s
3条回答
  •  执笔经年
    2020-12-10 21:51

    You shouldn't have created a 'standard' git repo on the remote host, as Brian Campbell noted. What you should do:

    1. copy all the files you wish to place under version control to a directory on your local machine.

    2. delete them and their containing directory on the remote host.

    3. still on the remote host create a new directory called projectname.git (substitute a meaningful name for projectname), cd into it, and run git init --bare

    4. on your local machine, in the directory in which you've placed your files:

      • run git init to initialise a git repo
      • run git add . to add all files and sub-directories
      • run git commit -m "Initial commit"
      • You should see something like [master agd27c9] Initial commit
      • run git remote add origin ssh://hostaddress/path/to/dir/projectname.git (you may have to modify this slightly, if you usually access your remote host using ssh://user@hostaddress, for instance)
      • run git push origin master
    5. You should see a message indicating connection to your remote host, and some output from git indicating that the push was successful. It usually looks like:
      Counting objects ...
      Delta compression ...
      Writing objects ...
      Total ...
      To ssh:// ...
    6. If everything happened as described above, you're done. You could add default push and merge if you wish:
      • git config branch.master.remote origin && git config branch.master.merge refs/heads/master

提交回复
热议问题