DEV Community

Rubitha Duraisamy
Rubitha Duraisamy

Posted on

Day 2 Advance git commands

Posting Project to GitHub — Full Commands

  1. Initialize Git (only if not already done)
    bash
    Copy
    Edit
    git init
    👉 This makes your project folder a Git repository.

  2. Add all files
    bash
    Copy
    Edit
    git add .
    👉 This stages all the files to be committed.

  3. Commit your changes
    bash
    Copy
    Edit
    git commit -m "Initial commit"
    👉 This saves your changes with a message.

  4. Create a repository on GitHub
    Go to https://github.com

Click ➡️ New Repository

Don't initialize with README (you already have files locally).

Copy the GitHub URL (it looks like https://github.com/username/repo-name.git)

  1. Connect local repo to GitHub
    bash
    Copy
    Edit
    git remote add origin https://github.com/username/repo-name.git
    👉 Replace https://github.com/username/repo-name.git with your actual GitHub repo URL.

  2. Push to GitHub
    bash
    Copy
    Edit
    git push -u origin main
    👉 If your branch is called master instead of main, then:

bash
Copy
Edit
git push -u origin master
✅ Your project will now be live on GitHub
Image description

Image description
git blame
See who changed each line of a file and when.

bash
Copy
Edit
git blame filename
Useful for debugging historical changes in the code

Top comments (0)