Search

Git's Articles

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

fatal: unable to access repo: The requested URL returned error: 403
While accessing any repository in GitHub, you might get error "fatal: unable to access 'https://github.com/repo.git/': The requested URL returned error: 403". This is because you used wrong authentication while accesing repository. If you use usename and password while accesing repository in GitHub, then you will get error "Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information." In this linked article describes: In July 2020, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations. Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com. So you have to create and use Personal Access Token(PAT) instead of password to use access Git repository. You need to create Personal access tokens(PAT) at Developer Settings option in Settings menu. Also note that, when creating the Personal Access Token, you have checked all the required scope, otherwise you will still get 403 error. After you have successfully created token, save it to somewhere because you couldn't get it second time. Though you can regenerate token from Setting menu, but you have to update the token at applications using this token. So, this way, you can generate Personal access token and use it while accessing GitHub repository and others instead of password.
How to Upload a Project on Git
Suppose you are working in a big project and after some changes you want to revert some changes and want to work with new codes. Also when team is working in one project, then how to share their work? Here comes the Git! Git is the open source distributed version control system developed by Linux Torvalds as a part of Linux Kernal development. Git makes all community developers to share your project and work colloborately. In this article, we will not go deep about what is git, or how git works. Rather than we will upload project on GitHub using command line tool, one of the most popular Git repository hosting service. There are also many other popular Git service providers are available, like Bitbucket, GitLab, which provides free private repository. You can go any of them, all commands will be same for all Git client. So let's start. Git installation and setup First of all, you need to have git installed in your local machine. Run this command in Terminal to check if git is already installed. git --version You should get git version in output git version 2.7.4 Else you need to install git with bellow command: sudo apt-get install sudo apt-get install git After that Git is installed, you need to set your username and email address. All your commits will be shown with this information. git config --global user.name "jiteshmeniya" git config --global user.email jiteshmeniya99@gmail.com GitHub account Now if you don't have GitHub account, create new Github account. For GitHub, go to GitHub and register. All of your uploaded project will be stored in your account. After you have created account, create new GitHub repository. Upload project to GitHub Now your git repository is ready to upload project, perform following command to upload project in Git. For that, go to project root directory in Terminal. cd my-new-project Initialise with Git repository in project git init Stage all files to Git index git add --all You can also add selected files to index git add file1 file2 Commit your changes git commit -m "Initial upload" Now add your remote url to local project. If you want to add ssh url, then you need to set ssh key in your local machine. origin is the name of git repository in your local project. You can add as many git repository to your local project as you want. git remote add origin https://github.com/jiteshmeniya/My-new-project.git and push the code in git repository git push -u origin master If you added HTTPS remote url, then you need to enter your GitHub username and password. Now your project is live on GitHub. Some important Git command. You can track your changed files in local project. git status You can also track changes made in your file. git diff file.txt Update your local project from Git repository git pull origin master You can clone(download) public git repository git clone repository-url Check all Git remote repositories git remote -v Get repository url of origin  git remote get-url origin Remove origin repository url from project git remote rm origin Change repository url git remote set-url origin new-url Show your all local branch git branch Create a new branch git branch branch-name Change working branch git checkout branch-name Merge new branch to master git checkout master git merge branch-name Conclusion This way you can easily upload your local project to new git repository. Please comment bellow if we forget to add basic Git command.