My first git...
Last updated
Last updated
My First GitHub Experience: Uploading My First Project with Personal Access Token (PAT)
Starting out with Git and GitHub can be intimidating, especially if you're new to version control and the whole concept of pushing your code to a repository. But once you get the hang of it, GitHub becomes an invaluable tool for managing projects and collaborating with others. Let me walk you through my very first experience of uploading a project to GitHub, step by step, including the commands I used and how I set up my Personal Access Token (PAT) for authentication.
Before I could start using Git and GitHub, I made sure that Git was installed on my system. If you havenโt done so yet, you can download and install Git from the official website.
Once Git is installed, I opened up the terminal or command prompt and ran the following command to check that everything was set up correctly:
This command should return the installed version of Git, which meant I was ready to proceed.
I had already created a project folder on my local machine, so I navigated into that folder using the terminal. From there, I initialized it as a Git repository using the following command:
This command created a .git
folder in my project, making it a Git repository. Itโs like telling Git, โHey, this folder is now under version control!โ
Now, I added all my files to the staging area using the following command:
The git add .
command tells Git to track all files in the current folder and any subfolders. The dot (.
) means "all files."
Once the files were staged, I needed to commit them to my local repository. A commit is essentially a snapshot of my project at a specific point in time. Here's the command I used:
The -m
flag allows me to add a message to the commit, in this case, "Initial commit," to describe what this commit represents.
Next, I had to link my local Git repository with the remote repository I created on GitHub. I did this by adding the remote URL provided by GitHub during the repo creation process. The command looked like this:
At this point, when I tried pushing my code to GitHub, Git asked me to authenticate. Instead of using my GitHub password (which is no longer allowed for Git operations), I used a Personal Access Token (PAT). I had already created a PAT in my GitHub account settings under Developer settings -> Personal access tokens.
To push my code securely, I entered the following command:
Git then prompted me for my GitHub username and password. I entered my GitHub username, and instead of my password, I pasted the PAT that I had generated earlier. This was my first time using PAT for authentication, and it worked like a charm!
Once the push was complete, I went to my GitHub repository page and refreshed it. There it was! My project had successfully uploaded to GitHub. I could see all my files, and the commit history reflected my first commit with the message "Initial commit."
Now that my project was live on GitHub, I could continue to make changes, commit them, and push them to the remote repository. In the future, I could simply make changes locally and run:
This workflow would ensure that my project stays up to date on GitHub, and I could easily collaborate with others if needed.
To check the git status we can use :
& to download the files back locally we can use the following command :
Next, I went to GitHub () and created a new repository. I gave my repository a name (something meaningful), and left it as a public repository (you can choose private if you wish). After the repo was created, GitHub provided me with a URL, which would be used to link my local project to the online repository.