10

I'd like to delete some old forks I drawn but I cannot remember whether I ever pushed any changes to those forks.

How can I see whether I created a branch or whether I commited any changes to any branch in my repository's fork?

jwodder
  • 54,758
  • 12
  • 108
  • 124
AxD
  • 2,714
  • 3
  • 31
  • 53

1 Answers1

6

In the GitHub UI: Just click on the "commits" button and see if one of the most recent commits is yours. This requires manually looking through the commits, so it will only work well if your commit is one of the most recent (because you committed to your fork and never pulled updates) or if there's a small number of commits and you can look through them all.

Using Git: This method is fool-proof, even for repositories with thousands of commits.

  1. Clone your fork. git clone ...
  2. Add the other repo as upstream. git remote add upstream ...
  3. Fetch the upstream repo. git fetch upstream
  4. Use rev-list to look for commits in master that aren't merged to the upstream fork: git rev-list --oneline master ^upstream/master

If rev-list doesn't list any commits, then there are no commits in your master branch that haven't been merged to the upstream fork, and your repository can be safely deleted.


If you may have committed on branches other than master:

  1. Make sure you have a local copy of any branch in your fork of the repository that you might have committed to. Normally, this would already exist unless you're on a different computer or something.
  2. List all your local branches. git branch
  3. For each local branch that you want to check, look for commits that are not in upstream: git rev-list --oneline local-branchname ^origin/master. Or compare against some other branch than upstream/master depending on where it would have been merged to.
mkasberg
  • 16,022
  • 3
  • 42
  • 46
  • Very interesting! Yet, I need to know whether I may have created any branches (not present in the upstream repository). How could I possibly find out what branches I may have created? – AxD Dec 14 '18 at 16:14
  • Yes, I'll add to my answer above. – mkasberg Dec 14 '18 at 22:42
  • Thanks, pal. So, in order to find any changes of mine, I would be required to write a script that's looping through all the branches found by `git branch` and finds the number of commits using `git rev-list ...`. Any commit found would signal a personal commit then, right? – AxD Dec 18 '18 at 11:27
  • Essentially, yes. Because of the arguments to `git rev-list`, it's listing commits that exist in `local-branchname` that don't exist in the other arg `origin/master`. So if it finds any, you have commits that haven't been merged to `origin/master` (or whatever branch you put there). – mkasberg Dec 18 '18 at 16:20