Web Development

Github on Linux: I could push to my repo yesterday but now I get an error

This issue can be caused by multiple problems, but when I ran into this issue it was because my access token had expired but my SSH key was fine.

If you are having this issue and suspect that it may be caused by the token expiration, follow the steps below.

First, generate a new access token on github by following this very simple guide: and do not forget to copy the token because you cannot see it again.

Clone a repo to test pushes on and open that location in the terminal.

Run the command:

The output of this command will be the remote URL(s) associated with that particular repository. If there are entries there, you can remove them with the follow command:

Add a new remote URL built with the token, the username and the repository name by running the following command but substituting in your own values:

After you add that new remote URL you can try to push but you will get an error:

fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

As described in the error, run the command:

and now the pushing will work. Happy coding!