Solutions To Some Common GitHub issues
Published: 2023-05-26 13:28:50

Sometimes, you may come across various challenges when using GitHub. In this blog post, we will explore some common issues we encounter and provide practical solutions to help you overcome them. Let's dive in!


## <u>**Error-1: Git Configuration error**</u>



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fropy5aq37gs2izy97a.png)

**<u>Solution</u>**

**Step 1:** The image shows two commands in the terminal. If you receive these commands, **execute them one by one in your terminal**. 

```
git config --global user.email "your github email"
git config --global user.name "your github name"
```

**Step-2:** A pop-up with **sign in with browser** will appear. Make sure you are logged in your GitHub Account. Click on the 
**sign in with browser** and then click **Authorize Visual Studio Code button**

**Step 3:** Go to your terminal again and run these commands

```
git branch -M main
git remote add origin "your repo link"
git push -u origin main 
 
```


## <u>**Error-2: (e.g git pull...) before pushing again**</u>



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cveqxg7w7a40pne5ssq4.png)



**<u>Solution</u>**

If you're submitting your code to GitHub for the first time, open your terminal again and run these commands:
```
git push -u origin main -f
```

or

If you've already pushed your code to the GitHub repo more than once.

```
git push -f
```

## <u>**Error-3 : src refspec main does not match any**</u>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r4xubiwsge84r0iookh.png)

**<u>Solution-1</u>**

**Step 1:** Go to GitHub **Settings** and then go to **Emails**

**Step-2:** Uncheck **Keep my email addresses private**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhblbyqjyf00430xiu48.png)

**Step-3:** Push your code again

**<u>Solution-2</u>**

Open your **Git bash terminal** and run the following commands one by one:

```
rm -rf .git
git init
git add .
git commit -m "added"
git branch -M main
git remote add origin <YOUR_GITHUB_REPO_LINK>
git push -u origin main -f
```

## <u>Error 4: Requested URL returned error: 403</u>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxxyohqctd20g459q7nr.png)

This error takes place when you do not have access to a repository.

**<u>Solution-1</u>**

**Step-1:** Check if you are pushing the code to your repository

```
git remote -v
```

**Step-2:** Open a new repository in your GitHub

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47lw0jjkqhgana3r1e8a.png)

**Step-3:** Copy your repository link

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsq498308yzjglmek1aq.png)

**Step-4:** Go to the terminal and write the following command:

```
git remote set-url origin your-repo-link
```
After the entering command, check if the git repository url changed. Write **git remote -v** on your terminal.

**Step-5:** Then, run these commands one by one

```
git branch -M main
git push -u origin main
```
**<u>Solution-2</u>**

https://dev.to/shafia/requested-url-returned-error-403-1pfm

Follow the solutions discussed above and get rid off your errors. 

Visit the link below and learn how to resolve the GitHub error "**Support for password authentication was removed**".

https://dev.to/shafia/support-for-password-authentication-was-removed-please-use-a-personal-access-token-instead-4nbk

 Don't let these common issues discourage you. Keep exploring, collaborating, and contributing on GitHub, and watch your skills grow. Happy coding!