GENERAL GIT COMMAND
Basic Git Workflow
1. Initialize a Git Repository
To start version controlling your project, navigate to your project directory in the terminal and run:
git init2. Stage Changes
Add files to the staging area to prepare them for committing:
git add <file> # Stage a specific file
git add . # Stage all changes in the current directory3. Commit Changes
Commit staged changes to the local repository:
git commit -m "Your commit message here"4. Push Changes to Remote Repository
Push committed changes to a remote repository (like GitHub):
git push origin <branch_name>5. Pull Changes from Remote Repository
Fetch and merge changes from a remote repository into your local repository:
6. Check Status
View the status of your repository, including tracked/untracked files and changes:
7. View Commit History
View a list of commits and their details:
8. Create a New Branch
Create a new branch for feature development or bug fixing:
9. Switch Branches
Switch to a different branch:
10. Merge Branches
Merge changes from one branch into another:
Additional Git Commands
1. Clone a Repository
Clone an existing repository from a remote server (like GitHub):
2. Remove Files
Remove files from the staging area and/or working directory:
3. Undo Changes
Undo changes made to files:
4. Configure Git
Set up user information for Git commits:
5. Inspect Changes
View the changes introduced by a specific commit:
6. View Remote Repositories
View the list of remote repositories associated with the current repository:
7. Rename and Move Files
Rename or move files within the repository:
8. Amend the Last Commit
Add changes to the last commit or modify its commit message:
9. Create Tags
Create lightweight or annotated tags to mark specific commits:
10. Checkout Specific Commit
Check out a specific commit by its commit hash:
11. Reset Changes
Reset the repository to a specific state:
12. Fetch and Merge Remote Changes
Fetch remote changes without merging them:
13. Rebase Commits
Rebase the current branch onto another branch or commit:
14. Ignore Files
Exclude files or directories from version control using a .gitignore file:
15. Show Differences with Previous Commit
View the changes introduced by the last commit:
Last updated