After a long time I created a repo on my Github account.Creating a repo is quite easy on Github, simply login to your account and click on ‘create repo’ button. After creating git repo, now it was time to push all my codes from my desktop to github repo.
After cloning the repo into my system, I copied all my coded into git cloned directory. And tried to push my code into gtihub repo. But got the error message “error: The requested URL returned error: 403 Forbidden while accessing https://github.com/sharadchhetri/skctheme.git/info/refs”
The error was quite clear that the problem was with URL. I again used my old generic steps for git. Finally it is solved and all codes are successfully pushed into github repo.
In below section, I am writing step by step how I pushed the code in Github repo successfully
Follow the given below steps from where(Desktop/Server) you want to push the code into Github repo :
Step 1: Clone the github repo into your system. (You should first create a repo in Github)
Get repo url at right hand sidebar of your repo page. Replace your github repo’s HTTPS url with
git clone https://github.com/USER-NAME/REPO-NAME.git
git clone https://github.com/sharadchhetri/testrepo.git
After cloning will be finished, you will find the directory name matching with the name of Github repo name you just cloned.
Step 2 : Copy your code or files to REPO-NAME directory
For example, I have saved my codes in my desktop at /home/sharad/MyCode directory. Here, I am copying all codes and child directories into REPO-NAME directory .
cp -rvf /home/sharad/MyCode/* /home/sharad/testrepo
Step 3 : Change to git cloned directory i.e REPO-NAME.
Step 4 : Set Github account username and email id for authentication
git config --global user.email "firstname.lastname@example.org" git config --global user.name "Your-Github-UserName"
Step 5: Set Github URL. (This section is actually solution of this problem)
git remote set-url origin https://Your-Github-UserNAme@github.com/Your-Github-UserNAme/REPO-NAME
git remote set-url origin https://email@example.com/sharadchhetri/testrepo.git
Step 6: Now add all files and directory by using below given command inside REPO-NAME directory
(There is a dot in command, can you see that!)
git add .
Step 7: Now write comment on commit
git commit -m 'my first commit'
Step 8: Now push the code in Github repo.
Be ready with your github account password because it will ask.
git push -u origin master
I hope the solution also work for you.