Tech TLDR;

  • Archive
  • Top Posts
  • GitHub
  • LinkedIn
  • Contact

Delete Fork Dependency of a Repository on Atlassian Stash or GitHub

May 30, 2014 by admin

Table of Contents

  • Solution for Atlassian Stash
    • Careful Approach
    • Faster Approach
  • Solution for GitHub
  • Conclusion

A colleague of mine forked a repo on Stash, just to re-use configuration. A better way of doing things would be to clone the original repo, keep the necessary config/setup files, delete .git folder, and re-initialize the new repo from scratch.

In our case, we only noticed the fork about a week into the project, so we didn’t want to lose the history for a week’s worth of changes. I tried finding an easy solution for getting rid of the fork reference, but couldn’t find any advice for Atlassian Stash.

As it turns out the problem had a really easy fix, following the steps bellow. Note that I took a more careful approach, to test things out.

Solution for Atlassian Stash

Careful Approach

  1. Created new repo named new-repo-test
  2. On my local version of the forked repo I did git remote set-url origin http://repo-link.com/new-repo-test.git
  3. On my local version of the forked repo I did git push origin master
  4. Verified that all of the changes that I wanted showed up in new-repo-test
  5. Deleted old-repo
  6. Renamed new-repo-test to old-repo
  7. NOTE: I had to update my remote to point to newly renamed repo using git remote set-url origin http://repo-link.com/old-repo.git. For
    everybody else it would work without having to update origin url, but all of the remote branched would be removed. If you want to preserve remote branches, check them out to your local directory first and then push your new repo to git using git push --all origin

Faster Approach

I haven’t tested it, but in theory same results can be accomplished by just:

  1. Deleting old repo
  2. Creating new repo with the same name
  3. Pushing local version, which will automatically will be placed into the new repo that was created, replacing the old repo

Solution for GitHub

I tested a similar approach on GitHub. If you want to have a version of a repo without fork reference, simply create new personal repo on GitHub, update your remote origin url (step 2 above) and push your repo. Beware, that you will lose GitHub wiki and any other GitHub specific meta data associate with the forked repo.

Conclusion

In conclusion, in ideal world people would only fork repos when they intended to sync with them and crate new repos otherwise. That being said, if you happened to fork a repo and don’t care about tracking it anymore, but you do want to save your local history, hopefully the steps outlined above will help.

Filed Under: Git, Tools

Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in