GitHub Basics: Essential Commands
GitHub is a popular platform for version control, collaboration, and code sharing. It’s an essential tool for developers, enabling them to track changes, work together on projects, and manage their code effectively.
Essential GitHub Commands
Here are some fundamental Git commands and their uses:
1. Git Init:
- Purpose: Initializes a new Git repository in the current directory.
- Command:
git init
2. Git Clone:
- Purpose: Clones an existing Git repository from a remote repository.
- Command:
git clone [repository_url]
3. Git Add:
- Purpose: Adds changes to the staging area, preparing them for commit.
- Command:
git add [file_name]
orgit add .
(to add all changes)
4. Git Commit:
- Purpose: Commits changes from the staging area to the local repository.
- Command:
git commit -m "[commit message]"
5. Git Push:
- Purpose: Pushes changes from the local repository to a remote repository.
- Command:
git push origin [branch_name]
6. Git Pull:
- Purpose: Fetches changes from a remote repository and merges them into the local branch.
- Command:
git pull origin [branch_name]
7. Git Branch:
- Purpose: Creates, lists, or deletes branches.
- Commands:
- Create a new branch:
git branch [branch_name]
- List all branches:
git branch
- Delete a branch:
git branch -d [branch_name]
- Create a new branch:
8. Git Merge:
- Purpose: Merges changes from one branch into another.
- Command:
git merge [branch_name]
9. Git Status:
- Purpose: Shows the current state of the working directory.
- Command:
git status
10. Git Log:
- Purpose: Displays the commit history.
- Command:
git log
By mastering these fundamental Git commands and practices, you can streamline your development workflow and collaborate effectively with other developers.
Comments