1

.git/config

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@github.com:myusername/wp-theme.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
    remote = dreamhost
    merge = refs/heads/main
[remote "dreamhost"]
    url = ssh://myusername@server.domain.com/~/my.domain.com.git
    fetch = +refs/heads/*:refs/remotes/dreamhost/*

I am having a hard time pulling my code from github and pushing it to my dreamhost server.

I run (on my local computer)...

 git push -u dreamhost main

and then run (on the server)..

git clone ~/my.domain.com.git ~/cloned.my.domain.com.git

However the folder is empty. What am I doing wrong?

user2012677
  • 5,465
  • 6
  • 51
  • 113

1 Answers1

2

In your empty cloned repository folder ~/cloned.my.domain.com.git, check the output of:

git branch -avv

The idea is: your local computer might have a recent Git, with a default branch of main.
While your target bare repository (~/my.domain.com.git) might have as default branch master.

If you push the main branch, but, on the target side, clone the default master branch, the latter would have no commit/file to show.
You would need to go back to the bare repository (~/my.domain.com.git), and change its default branch.

If origin/main is present:

git checkout main
user2012677
  • 5,465
  • 6
  • 51
  • 113
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I get " remotes/origin/main 8a1c8e0 Commit for add all wp files", so it sees the last git commit, but does not display the files. if I do just "git branch" it shows nothing. – user2012677 Aug 19 '21 at 22:15
  • @user2012677 Then start with `git switch -c main`, and see of the files are restored. – VonC Aug 19 '21 at 22:32
  • Got this error: "git: 'switch' is not a git command. See 'git --help'." – user2012677 Aug 19 '21 at 22:49
  • @user2012677 Well done. If you upgrade git, you will get git switch, less confusing than checkout: https://stackoverflow.com/a/57066202/6309 (Git 2.23, Q3 2019). – VonC Aug 20 '21 at 00:44