-
Notifications
You must be signed in to change notification settings - Fork 85
Description
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 statusThis 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 initAfter 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.gitThis 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.mdThis 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 mainThis 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 mainThis fetches and merges changes from the remote main branch.
These basic commands are foundational for working with Git and collaborating on projects.