简体   繁体   中英

Create a remote git repository and push from local

These are my steps to create a remote git repository and push to it the data that I have in my local machine:

# mkdir -p git/sports.git
# cd git/
# cd sports.git/
# git init --bare
Initialized empty Git repository in /home/tirengarfio/git/sports.git/
# exit
logout
Connection to 173.203.57.258 closed.
(master)]$ git remote add origin ssh://root@173.203.57.258/home/tirengarfio/git/sports.git
(master)]$ git push --all
root@173.203.57.258's password: 
Counting objects: 1271, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1236/1236), done.
Writing objects: 100% (1271/1271), 1.11 MiB, done.
Total 1271 (delta 37), reused 0 (delta 0)
To ssh://root@173.203.57.258/home/tirengarfio/git/sports.git
 * [new branch]      master -> master

When I go to /home/tirengarfio/git/sports.git/branches it is empty..

Hope this answers your question(s)...

Where are my files?

Git does not store the files in plain. It compresses them and stores then in a tree (and in so called packfiles). There is an article on gitready that explains the directory structure. For more details, you could refer to the manpage I linked below.

For details about the internal format, please see chapter 9 of the Pro Git book. Here is an online version:

Why is the branches directory empty?

The branches directory seems to exist only for legacy purposes. Which is documented in man 5 gitrepostory-layout :

branches

A slightly deprecated way to store shorthands to be used to specify URL to git fetch, git pull and git push commands is to store a file in branches/ and give name to these commands in place of repository argument.

For more details, see: What is the .git/branches folder used for?

How do I get the files out of the .git directory?

If you just want to access your files, the simplest way would be to clone your repository.

$ git clone /home/tirengarfio/git/sports.git/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM