Unlink a GitHub Project with gh project unlink
Use gh project unlink to detach a GitHub Project from a repository or team without deleting any of the three. The examples use GitHub CLI 2.45.0 from the Ubuntu gh package. Allow about ten minutes, most of it spent confirming the project number and target before you change anything.
The route
Jump straight to the step you need, or tick off Done means at the end.
- State-changing and authenticated. You need
ghinstalled and logged in with permission to change the project association. Nosudoneeded. - One target only. Pick exactly one of
--repo,--team, or the current repository fallback.
1. Check the installed command
Read the local help first. It is a read-only check:
$ gh project unlink --help
Unlink a project from a repository or a team
USAGE
gh project unlink [<number>] [flags]
The command takes a project number, an optional owner, and one repository or team target. There is no dry-run flag in this version, so the final command is an immediate change.
Checkpoint
Confirm the binary and package version you are about to use.
$ command -v gh
/usr/bin/gh
$ gh --version | head -n 1
gh version 2.45.0
2. Confirm authentication and ownership
Check the account before you touch a project. A valid login can still be the wrong personal account or the wrong GitHub Enterprise host.
$ gh auth status
Logged in to github.com account YOUR_LOGIN
- Personal project. The owner is your login, or the special value
@me. - Organisation project. The owner is the organisation login.
- Cross-organisation work. The project owner is not necessarily the repository owner.
Warning
If the status check shows the wrong host or account, stop. Fix authentication with the normal gh auth workflow and rerun the check. Do not try random owner values instead of fixing the session.
3. Identify the project number and target
The positional number is the project number. It is not an issue number and not a repository ID. Get it from the project listing or the project URL, then write it down next to the exact repository or team name.
For a repository association, prepare a command like this:
$ PROJECT_NUMBER=123
$ OWNER='YOUR_LOGIN'
$ REPOSITORY='YOUR_REPOSITORY'
$ printf 'project=%s owner=%s repo=%s\n' "$PROJECT_NUMBER" "$OWNER" "$REPOSITORY"
project=123 owner=YOUR_LOGIN repo=YOUR_REPOSITORY
For a team association, the target changes to a team name:
$ TEAM='YOUR_TEAM'
$ printf 'project=%s owner=%s team=%s\n' "$PROJECT_NUMBER" "$OWNER" "$TEAM"
project=123 owner=YOUR_LOGIN team=YOUR_TEAM
Warning
Never put both --repo and --team in one invocation, because they describe different association types. With neither, gh project unlink uses the repository of the current directory, which is only safe once you have checked that directory.
4. Review the current repository context
If you plan to rely on the current-directory default, inspect it immediately before unlinking:
$ git rev-parse --show-toplevel
/path/to/YOUR_REPOSITORY
$ git remote -v
origin https://github.com/YOUR_LOGIN/YOUR_REPOSITORY.git (fetch)
origin https://github.com/YOUR_LOGIN/YOUR_REPOSITORY.git (push)
When in doubt, pass --owner and --repo explicitly. A shell prompt sitting in another clone can silently pick a different repository. The fallback is also no use for a team association, because it cannot select a team.
Checkpoint
You should be able to say the project number, owner and one exact target aloud. If any value is uncertain, stop and verify it in GitHub.
5. Unlink a repository
Use --repo:
$ gh project unlink "$PROJECT_NUMBER" \
--owner "$OWNER" \
--repo "$REPOSITORY"
Success normally prints nothing and exits with status zero. Capture that status as your checkpoint:
$ printf 'exit status: %s\n' "$?"
exit status: 0
Warning
An empty terminal response is not a preview. If the command exited successfully, the association has already changed.
If it fails, read the error before retrying. These are all different problems:
- Authentication. The session is not valid for this host.
- Permissions. Your account cannot change the association.
- Wrong owner or project number. The project cannot be found.
- Not linked. The repository was never linked to the project.
6. Unlink a team
For an organisation project linked to a team, use --team instead:
$ gh project unlink "$PROJECT_NUMBER" \
--owner "$OWNER" \
--team "$TEAM"
Again, a zero exit status is the useful immediate verification:
$ printf 'exit status: %s\n' "$?"
exit status: 0
The owner identifies the project owner. It does not turn a personal project into an organisation project, and it does not grant access to a team. Confirm that your authenticated account can administer both the project and the association before you run this.
7. Relink if you removed the wrong association
Unlinking does not delete the project, but it is still a remote change. If you picked the wrong target, relink the same project with the matching gh project link command:
$ gh project link "$PROJECT_NUMBER" \
--owner "$OWNER" \
--repo "$REPOSITORY"
For a team, substitute --team "$TEAM". Verify the owner and target before relinking.
Recovery
If the original association had other permissions or project settings, check them in GitHub afterwards. Relinking restores the link, not unrelated configuration.
Done means
- Version and account checked. You know which
ghversion and authenticated account you used. - Project confirmed. The project number and owner were verified.
- One target selected. Exactly one of
--repo,--team, or a deliberately checked current repository. - Exit status zero. The command returned
0. - Way back known. You know the matching
gh project linkcommand if the wrong association was removed.