gitgithub

GitHub: Can I see whether I made changes to a fork?


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?


Solution

  • 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.