0

I was given a repository and commited my initial files there, as I normally would. Unfortunately, the scope of the project changed, and I have to use the same repository, but wipe it and start again with a different base.

I pulled my new base from an existing repository, and have set the remote url to the one of the repo I want to use. After that, I tried to do the following:

git add . 
git commit -m "Project base change"
git push -u -f origin master

But I'm getting the following error

error: src refspec master does not match any.

Since this is something I really want to be careful with, I'd like to know the correct way of doing this.

Xcodian Solangi
  • 2,342
  • 5
  • 24
  • 52
  • 1
    Can you do a 'git branch' and paste the result here? – codePrady Oct 24 '17 at 10:50
  • It has the develop branch, only –  Oct 24 '17 at 10:52
  • Then you cannot push `master`, right? – phd Oct 24 '17 at 11:26
  • Yes, that's pretty much the issue. I want to start the repo fresh, but am not sure on how to proceed correctly. –  Oct 24 '17 at 13:14
  • why use -u and -f flag here? why can't you just push without forcefully? check `git show-ref`, and see where it points to? normal `git push origin master` will work. – danglingpointer Oct 24 '17 at 13:29
  • paste : "git status" and "git remote -v" – jo_ Oct 24 '17 at 13:32
  • It doesn't work. There are several refs shown which I'm not sure I can show here. git push origin master doesn't work. It gives the same error I mentioned above. I can't paste the remote info here. The status says I'm working on the branch I created to work on the previous version. `On branch develop Your branch and 'origin/develop' have diverged, and have 152 and 3 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean` –  Oct 24 '17 at 13:32

1 Answers1

0

Did you try

git branch -r

This will give you remote branches. If it shows master, check if you are able to do git checkout master.

As per details provided, I assume you are working on "devlop" branch and want to push the entire branch to master,is it?

saurabh14292
  • 1,281
  • 2
  • 10
  • 12
  • I am currently trying to use a new project base to work on what I'm supposed to do. I have a different project, and I need to replace everything that's on the repository with the different files I'm going to use. The develop branch was made as that's how my workflow is. Right after pushing my code into the repo, and creating the branch, I was told I had to use a different project instead of what I just pushed. In sum, I need to wipe the repository and add a completely different project to it –  Oct 24 '17 at 15:34
  • Check this : https://stackoverflow.com/questions/5363857/delete-all-files-and-history-from-remote-git-repo-without-deleting-repo-itself – saurabh14292 Oct 24 '17 at 18:25