GitHub is a popular platform for version control and collaboration that allows developers to host and share their code repositories. Whether you’re new to coding or an experienced developer, this step-by-step guide will walk you through the process of getting started with GitHub, from registration to creating your first repository and pushing code.
Table of Contents
Step 1: Registering on GitHub
- Go to the GitHub homepage (https://github.com).
- Click on the “Sign up” button in the top right corner.
- Fill out the registration form with your desired username, email address, and password.
- Choose a plan (you can start with the free plan).
- Complete the “Verify your account” step, following the instructions sent to your email.
- Once verified, you’re ready to move on to the next step.
Step 2: Creating Your First Repository
- Log in to your GitHub account.
- Click on the “+” icon in the top right corner and select “New repository”.
- Give your repository a name and optional description.
- Choose whether you want your repository to be public or private.
- Initialize this repository with a README if you want to start with a default README file.
- Click on the “Create repository” button.
- Congratulations! You have successfully created your first repository on GitHub.
Step 3: Installation of Git
If you haven’t installed Git on your machine, you’ll need to do that:
- For Windows: Download and install Git from Git for Windows.
- For macOS: Git is usually pre-installed. If not, you can install it using Homebrew:
brew install git
. - For Linux: Use your package manager to install Git. For example, on Ubuntu:
sudo apt-get install git
.
Step 4: Configuration
After installation of the GitHub, now lets configure the GitHub, now lets configure the machine to use GitHub.
- Open a terminal (Command Prompt, Git Bash, or Terminal).
- Set your Git username:
git config --global user.name "Your Name"
. - Set your Git email:
git config --global user.email "[email protected]"
.
Step 5: Cloning the Repository
Now we are ready to clone the repository to our local machine. Follow steps below to clone the Git repository on your machine.
- On your repository page, click the green “Code” button.
- Copy the URL.
- Open your preferred code editor or terminal.
- Navigate to the directory where your code is located using the
cd
command. - In your terminal, navigate to the directory where you want to clone the repository.
- Run:
git clone <repository_url>
(paste the URL you copied)
Step 6: Adding and Committing Changes
Now we have cloned our repository to local machine, lets add a file and commit the changes to the repository.
- Create or add your project files to the cloned directory.
- In the terminal, navigate to your project directory.
- Run:
git add .
to stage all changes. - Run:
git commit -m "Initial commit"
to commit the changes.
Step 7: Pushing Changes to GitHub
Now, let’s push our change to the GitHub.
- Run:
git push origin master
(ormain
if you’re using the main branch). - Enter your GitHub username and password if prompted.
Step 8: Confirming Changes on GitHub
Let’s confirm our changes are available on GitHub repository.
- Refresh your GitHub repository page.
- You should see your committed files.
Conclusion
Congratulations! You have successfully registered on GitHub, created your first repository, and pushed your code to GitHub. This step-by-step guide should help you get started with the basics of GitHub. Remember to explore more advanced features and collaborate with other developers to make the most out of GitHub’s powerful version control and collaboration capabilities.