DEV Community

Cover image for GIT and GITHUB
VARSHINI
VARSHINI

Posted on

GIT and GITHUB

Step 1: Initialize the Git Repository
Command: git init
Action: Initializes a new Git repository in the current directory.

Step 2: Add a File to the Repository
Command: git add 24MCR123.txt
Action: Stages the specified file to be committed.

Step 3: Attempt to Commit Changes
Command: git commit -m "Added personal details"
Action: Tries to commit the staged file but fails due to missing user identity.

Step 4: Configure Git Global User Email
Command: git config --global user.email "varshinithirunavukkarasu2006@gmail.com"
Action: Sets the global email identity for Git commits.

Step 5: Configure Git Global User Name
Command: git config --global user.name "Varshini2806"
Action: Sets the global username for Git commits.

Step 6: Retry Committing Changes
Command: git commit -m "Added personal details"
Action: Successfully commits the changes now that the identity is set.

Step 7: View Commit Log
Command: git log
Action: Displays the history of commits, showing commit hash, author, date, and message.

Step 8: Add a Remote Repository
Command: git remote add origin https://github.com/Varshini2806/24MCR123.git
Action: Links the local repository to a remote GitHub repository.

Step 9: Check Current Branch
Command: git branch
Action: Lists all local branches (shows * master as current branch).

Step 10: Rename Branch from master to main
Command: git branch -M main
Action: Renames the current branch to main.

Step 11: Verify New Branch Name
Command: git branch
Action: Confirms the current branch is now main.

Image description

Step 12: Push Local Branch and Set Upstream to Remote
Command: git push -u origin main
Action: Pushes the local main branch to the remote named origin and sets the upstream (tracking) relationship between local main and remote main.

Step 13: Stage a Modified File
Command: git add 24MCR123.txt
Action: Stages the updated file 24MCR123.txt to prepare it for committing.

Step 14: Commit the Changes
Command: git commit -m "updated"
Action: Commits the staged file with the message "updated", indicating a change has been made.

Step 15: Push the Commit to the Remote Repository
Command: git push -u origin main
Action: Pushes the latest commit to the remote repository. The -u flag ensures the local branch continues tracking the remote branch.

Image description

Image description

Top comments (0)