Steps to Push code to Github ->
- Create a new repository on Github
After creating repository on github , move to linux or git bash.
Move into that folder where files are present.
- Now initialize the folder with git init to make it a git repository.
git init
- Add changes in local repository . If you made any changes then first you have to add these changes in the local repository and stage them for the commit. Below command will help you to do it.
git add .
- Commit the changes and prepare it for the remote repository so we can push it . Consider the command given below.
git commit -m "first commit"
- Add remote origin. Type the below command.
git remote add origin https://github.com/username/repositoryname.git
- At last, execute the command below to push the changes in remote repository.
git push -u origin main
- If the above mentioned command does not work , try the below given command It will ask for the username and password ,
git push origin main --force
- Enter github username
- For password -> follow the steps
-> Go to Settings >> Developer Settings >> Personal Access Token >> Generate New Token >> Copy the new token and paste it in password
ย