DEV Community

Cover image for Github as an absolute beginner
Vanshaj Poonia
Vanshaj Poonia

Posted on

Github as an absolute beginner

GitHub is a popular platform for version control and collaborative development. Here's a detailed tutorial on how to use GitHub as a developer:

Step 1: Create a GitHub Account

If you don't have a GitHub account, go to GitHub and sign up for a new account.

Step 2: Install Git

GitHub uses Git for version control. Install Git on your machine if you haven't already. You can download it from the official Git website.

Step 3: Set Up Git

After installing Git, configure your username and email. Open a terminal and run the following commands, replacing "Your Name" and "your.email@example.com" with your name and email:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Enter fullscreen mode Exit fullscreen mode

Step 4: Create a New Repository

  1. Log in to your GitHub account.
  2. Click the "+" sign in the upper right corner and select "New repository."
  3. Fill in the repository name, description, and other options.
  4. Initialize this repository with a README if you want.
  5. Click "Create repository."

Step 5: Clone the Repository

To work on your local machine, you need to clone the repository:

git clone https://github.com/your-username/your-repository.git
Enter fullscreen mode Exit fullscreen mode

Replace your-username and your-repository with your GitHub username and repository name.

Step 6: Make Changes Locally

  1. Navigate to the cloned repository: cd your-repository.
  2. Create or edit files as needed.

Step 7: Add and Commit Changes

Once you've made changes, add them to the staging area and commit:

git add .
git commit -m "Your commit message here"
Enter fullscreen mode Exit fullscreen mode

Step 8: Push Changes to GitHub

Push your changes to the GitHub repository:

git push origin main
Enter fullscreen mode Exit fullscreen mode

Replace main with the name of your branch if it's different.

Step 9: Create a Branch

Create a new branch for a new feature or bug fix:

git checkout -b feature-name
Enter fullscreen mode Exit fullscreen mode

Step 10: Pull Requests

When your work on a feature or fix is complete, create a pull request on GitHub. Go to your repository, switch to the branch you created, and click "New pull request."

Step 11: Merge Pull Request

If your pull request is approved, merge it into the main branch on GitHub.

Step 12: Syncing Forks (if applicable)

If you forked a repository and want to sync it with the original, you can add a remote and pull changes:

git remote add upstream https://github.com/original-username/original-repository.git
git pull upstream main
Enter fullscreen mode Exit fullscreen mode

Additional Tips:

  • Issues: Use GitHub issues to track tasks, enhancements, and bugs.
  • README: Create a good README.md file to provide information about your project.
  • .gitignore: Create a .gitignore file to specify files and directories that Git should ignore.

This is a broad overview, and GitHub has extensive documentation if you need more details on specific features. Happy coding!

Top comments (0)