Today, I faced issues while creating a GitHub private repository, and I could solve them after spending some time. I want to write documentation so that anyone facing such an issue can resolve the problem.
Steps:
- Create a new repository.
2. Fill in the form by providing the repository name description, choosing the private option, and adding the readme file. Press Create repository.
3. You are expected to install git bash on your local PC or laptop. Then you go to the folder where all the files are there, which will be uploaded into the private repository.
4. Write the following commands on the Git Bash Terminal:
git config — global user.name “Your Name”
git config — global user.email “[email protected]”
git init
git add .
git status
git commit -m “first commit”
git branch -M main (changing from master to main)
git remote add origin [email protected]:Username/nameOfYourRepository.git
ssh-keygen -t rsa -b 4096 -C “[email protected]”
Now, press enter and then y. Then again, press enter for passphrase and similarly press enter for the same passphrase again. Thus the following will pop up.
The public key is generated here and the path is given. The path should be copied.
cat path
After running the following command the private key will be generated.
Now, you need to create an ssh key. The private key that is generated should be copied and pasted there.
Go to your GitHub account and then go to the settings.
Remember your email address will be there at the last .Then press Add shh key.
git push -u origin main
Your files will be pushed to the GitHub repository.
However, if you get any error like
! [rejected] main -> main (fetch first)
error: failed to push some refs to ‘github.com:Deboky/abc.git’
How will you solve this issue:
Technique:1
git pull — rebase origin main
Still, the issue is not resolved. Then use another technique.
Technique:2
git push origin main — force
