Reputation: 16801
My git repo is in a bit of a weird place right now, so let me explain how I got here...
cd /var
git clone https://github.com/..... www
cd www
mkdir my-site
mv !(my-site) my-site
cd my-site
Now when I run git status
, it claims that every single file has been deleted, and that the my-site
folder is not being tracked. Kind of makes sense: I moved every single file
To try and correct this I did the following:
git init
-- create a new repo in "my-site"git remote add origin https://github.com/.....
-- make this repo a "clone" of my origingit fetch --all
-- make sure I'm aware of the most recent commitsgit branch -u origin/master master
-- tell my local master to track origin masterWhen I did this I got the following error:
fatal: branch 'master' does not exist
Running git status
gives me the following:
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
...
nothing added to commit but untracked files present (use "git add" to track)
Running git branch -a
gives me:
remotes/origin/master
So I know I'm on a local master and I know a remote master exists, but I can't seem to tie the two together.
Upvotes: 2
Views: 7278
Reputation: 1040
may be a bit long winded, but :
git checkout -b temp-branch
git branch -D master
You may want to commit files to temp-branch here or stash them
git checkout origin/master --track
git merge temp-branch
General house keeping (not necessary)
git branch -D temp-branch
It's a bit hacky, but should do the job
Upvotes: 1
Reputation: 321
There are no commits in the repo you initialised inside my-site
, which is what's causing the hiccup in the git branch -u origin/master master
command. You could run git reset origin/master
in my-site
, after which git branch -u origin/master
will set the upstream as intended.
You could also blow away all contents of www
and just clone the repository into www/my-site
, which seems less fiddly!
Upvotes: 6