Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Lakshmi Pritha Nadesan
Lakshmi Pritha Nadesan

Posted on

Day 2 - GIT commands

Creating Git Folder:

Now, let's create a new folder for our project

mkdir Projectnamecd Projectname
Enter fullscreen modeExit fullscreen mode

mkdir makes a new directory.
cd changes the current working directory.

Clone an Existing Repository:

Copies a remote repository to your local machine.

git clone <repository_url>
Enter fullscreen modeExit fullscreen mode

This is useful when you want to contribute to an existing project.

Check the Status of Your Repository:

Shows which files have been modified, staged, or untracked.

git status
Enter fullscreen modeExit fullscreen mode

Always run this before committing to see what’s changed.

Add Files to Staging:

Moves changes from the working directory to the staging area.

git add <file_name>    # Add a specific filegit add .              # Add all changes
Enter fullscreen modeExit fullscreen mode

Staging means preparing files to be committed.

Commit Changes:

Saves the staged changes permanently in the repository.

git commit -m "Your commit message"
Enter fullscreen modeExit fullscreen mode

The commit message should describe what changes were made.

Check Your Git Configuration:

To verify your Git username and email, run:

git config --global user.namegit config --global user.email
Enter fullscreen modeExit fullscreen mode

List All Branches:

Shows all available branches in the repository.

git branch
Enter fullscreen modeExit fullscreen mode

The current branch will have a * next to it.

Create a New Branch:

Creates a new branch without switching to it.

git branch <branch_name>
Enter fullscreen modeExit fullscreen mode

Branches help in working on different features separately.

Switch to Another Branch:

Moves to an existing branch.

git checkout <branch_name>
Enter fullscreen modeExit fullscreen mode

Check Commit History:

Shows a list of all previous commits.

git log
Enter fullscreen modeExit fullscreen mode

Show Changes in Files:

Compares modified files with the last committed version.

git diff
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I am studying Python Full Stack Developer course
  • Joined

More fromLakshmi Pritha Nadesan

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp