Skip to content

Explain basic Git commands with examples #90

@steveb4088

Description

@steveb4088

Explain Basic Git Commands

This issue is to provide a clear explanation of essential Git commands for beginners, along with practical examples for each of them.

1. git status

Description: Shows the current state of the working directory and staging area.
Example:

git status

This command will list any changed files, files staged for commit, and files not tracked by Git.

2. git init

Description: Initializes a new Git repository in the current directory.
Example:

git init

After running this, you’ll see a .git folder created in your directory.

3. git clone <repo-url>

Description: Makes a local copy of a remote repository.
Example:

git clone https://github.com/example/repo.git

This clones the repository into a new folder named repo.

4. git add <file>

Description: Adds changes in a file (or files) to the staging area.
Example:

git add README.md

This stages README.md for the next commit.

5. git commit -m "message"

Description: Commits staged changes to the local repository with a brief message.
Example:

git commit -m "Add initial README"

6. git push

Description: Uploads local commits to the remote repository.
Example:

git push origin main

This pushes your local main branch changes to the remote repository.

7. git pull

Description: Fetches and integrates changes from the remote repository to your current branch.
Example:

git pull origin main

This fetches and merges changes from the remote main branch.


These basic commands are foundational for working with Git and collaborating on projects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions