1

I created my first GitHub repository using GitHub Desktop (Windows). It is a real mess with many revisions that are quite meaningless and some versions of files that I would rather were never uploaded. This was the result of a lot of experimenting to get the feel for how things would appear on GitHub. I want to get rid of all the history versions.

I am tempted to just copy my files on my drive to another folder then delete the repository folder from my drive. Also delete it from GitHub.

Then create a new repository with GitHub Desktop, perhaps with the same name or with a different name then rename it to the original. Could it be a simple as that or will GitHub still retain the files somewhere?

I haven't tried this because in my searching I keep finding all the complex steps to be performed to remove histories or remove files.

I sort of feel that what I am proposing is too simple.

Any opinions?

PeteC
  • 129
  • 1
  • 11

3 Answers3

1

All of this got too confusing. I just did what I said in the start of the thread. It seems GitHub Desktop has some Username/Password problem and won't let me "Publish branch".

So I went to GitHub and created a new repository and uploaded all the files from my local folder.

It looks good to me.

There may be problems in the future. I guess I'll cross that bridge when (if) I come to it.

PeteC
  • 129
  • 1
  • 11
-1

An alternative approach is to switch to command line and:

  • delete the .git folder in your repository
  • recreate it (git init .)
  • reset the origin remote: git remote add origin https://github.com//
  • Make a first commit with your current content:

    git add .
    git commit -m "first commit"
    
  • overwrite everything on the remote repo

    git push --force -u origin master
    

The end result will be the same repo but with only one commit.

You can then switch back to GitHub Desktop.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC,I have seen instructions like those or even identical. I didn't understand them. I don't see a .git folder in my repository (there is one in github Desktop). As for the command line,Is that from my Windows computer or do I have to use a Linux computer? Sorry to be so lost. – PeteC Jan 09 '20 at 21:50
  • @PeteC I meant in your repo on your local disk. (not on GitHub) – VonC Jan 09 '20 at 21:51
  • @PeteC For the command line, you can launch it from your GitHub Desktop (CMD or git bash): https://github.com/desktop/desktop/issues/809#issuecomment-275051069 – VonC Jan 09 '20 at 21:56
  • I got to the step "Make the first commit...." but it tells me "-m" is unknown switch. I tried some searches and everybody seems to have a different way of making a first commit. None similar to your method. What was the "m"switch supposed to do? – PeteC Jan 09 '20 at 22:45
  • @PeteC simply type the two commands separately. On the -m: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--mltmsggt – VonC Jan 10 '20 at 04:59
-1

From here.

First make sure you have Git for Windows installed, you are going to need to do git commands manually sooner or later.

Go to your local repository on your computer where your project is located. It's a good idea to show hidden files so you can see that you have the .git-folder and that the .gitignore-file is in place.

Go to the folder where the .git-folder is, right-click and click git bash here.

Now enter these commands:

Create Orphan Branch – Create a new orphan branch in git repository. The newly created branch will not show in ‘git branch’ command.

git checkout --orphan temp_branch

Add Files to Branch – Now add all files to newly created branch and commit them using following commands. Don't forget .gitignore!

git add .
git commit -m "the first commit" 

Delete master Branch – Now you can delete the master branch from your git repository.

git branch -D master

Rename Current Branch – After deleting the master branch, let’s rename newly created branch name to master.

git branch -m master

Push Changes – You have completed the changes to your local git repository. Finally, push your changes to the remote (Github) repository forcefully.

git push -f origin master

Git overview Git overview

Joel Wiklund
  • 1,697
  • 2
  • 18
  • 24