top of page

How to use Git and Github??


  1. Steps to Install Git on Windows 11


Go to the official Git website: https://git-scm.com/downloads


ree

Click “Download for Windows” — it will automatically detect your version.


Run the installer (Git-x.x.x-64-bit.exe).


  • Finish and verify installation:

    • Open Command Prompt or VS Code Terminal, and type:

      git --version

    • You should see something like:

      ree


Step 1: Create a New Repository on GitHub


1. Log in to your GitHub account.

ree

2. Click the + icon in the top-right corner and select "New repository".

ree

3. Enter a Repository name (e.g., my-git-practice).

4. Optionally, add a Description.

5. Choose between Public (visible to anyone) or Private (you control access). For this exercise, either is

fine.

6. Important: Do NOT initialize the repository with a README, .gitignore, or license file yet. We will

create the README locally. Leave these options unchecked.

ree

7. Click the "Create repository" button.


8. On the next page, you'll see instructions and a URL (HTTPS or SSH). Copy the HTTPS URL. It will

look something like https://github.com/your-username/my-git-practice.git.

ree


Step 3: Clone the Repository to Your Local Machine


1. Open your terminal or command prompt.

2. Navigate to the directory where you want to store your project locally using the cd


md my_practice

cd my_practice


ree

3. Use the git clone command followed by the URL you copied in Step 1:


git clone <paste_the_repository_url_here>


Replace <paste_the_repository_url_here> with the actual HTTPS URL. Example:



4. Git will download the repository (which is currently empty except for hidden Git configuration files)

into a new folder named after your repository (e.g., my-git-practice).

5. Navigate into your new project directory:


cd my-git-practice

Step 3: Create a File and Add it to Staging

1. Inside the my-git-practice directory, create a simple text file named README.md. You can

Windows Command Prompt:


echo # My Git Practice Project >README.md

Change to your repository



ree


2. Now, check the status of your repository:


git status

You should see README.md listed under "Untracked files". This means Git sees the file, but isn't

tracking changes to it yet.


ree

3. Tell Git you want to track this new file and include it in the next snapshot (commit) by adding it to the


git add README.md


Alternatively, you could use git add . to stage all new or modified files in the current directory.

4. Check the status again:


git status

You should now see README.md listed under "Changes to be committed".

ree

Step 4: Commit the Staged Changes

1. Now that the file is staged, commit it to your local repository's history.

Use the git commit


command with the -m flag to provide a descriptive message:

Bash


git commit -m "Add initial README.md file"


o The -m flag allows you to write the commit message inline. If you omit it (git commit),

Git will usually open a text editor for you to write a longer message.

o Good commit messages are crucial! They explain why a change was made.

ree

2. Check the status one more time:


git status

ree

It should now say something like "nothing to commit, working tree clean" and mention that your local

branch is ahead of origin/main (or origin/master).


Step 5: Push the Commit to the Remote Repository

1. Your commit currently only exists on your local machine. To share it with the remote repository


(GitHub/GitLab), use the git push command:

Bash

git push origin main

o origin: This is the default short name Git gives to the remote repository you cloned from.

o main: This is the name of the default branch in most modern Git repositories (historically, it

was often master). If you cloned an older repository or your setup uses master, you might

need to use git push origin master instead. Your git status output in the

previous step might give you a hint about the branch name.

2. You might be prompted to enter your GitHub/GitLab username and password (or a Personal Access

Token, which is more secure and often required now instead of passwords).

3. Once the push is successful, your local commit(s) have been uploaded to the remote repository.

Verification:

 Go back to your repository page on GitHub or GitLab in your web browser.

 Refresh the page.

 You should now see your README.md file listed, along with the commit message you used ("Add

initial README.md file").



$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

Recommended Products For This Post
 
 
 

Recent Posts

See All

Comments


© 2023 by newittrendzzz.com 

  • Facebook
  • Twitter
  • Instagram
bottom of page