https://github.com/fabianroy/git-commands
List of all basic git commands
https://github.com/fabianroy/git-commands
git git-commands
Last synced: 4 months ago
JSON representation
List of all basic git commands
- Host: GitHub
- URL: https://github.com/fabianroy/git-commands
- Owner: fabianroy
- Created: 2024-09-15T14:41:36.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-02-16T19:13:19.000Z (4 months ago)
- Last Synced: 2025-02-16T20:23:31.831Z (4 months ago)
- Topics: git, git-commands
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Certainly! Here’s a list of common Git commands explained in plain text:
### **Basic Git Commands**
- **Initialize a New Repository:**
- `git init`
Initializes a new Git repository in your project directory.- **Clone a Repository:**
- `git clone `
Creates a copy of an existing repository from a URL.- **Clone a Specefic Branch**
- `git clone -b `- **Check Repository Status:**
- `git status`
Shows the status of files in the working directory and staging area.- **Add Files to Staging Area:**
- `git add `
Adds a specific file to the staging area.- `git add .`
Adds all changed files in the current directory to the staging area.- **Commit Changes:**
- `git commit -m "Commit message"`
Commits the staged changes with a descriptive message.- **View Commit History:**
- `git log`
Shows the commit history of the repository.- **Show Changes Between Commits:**
- `git diff`
Displays the differences between changes.### **Branching and Merging**
- **List Branches:**
- `git branch`
Lists all branches in the repository.- **Create a New Branch:**
- `git branch `
Creates a new branch.- **Switch Branches:**
- `git checkout `
Switches to the specified branch.- **Create and Switch to a New Branch:**
- `git checkout -b `
Creates and switches to a new branch in one step.- **Merge a Branch into Current Branch:**
- `git merge `
Merges changes from the specified branch into the current branch.- **Delete a Branch:**
- `git branch -d `
Deletes the specified branch.### **Remote Repositories**
- **Add a Remote Repository:**
- `git remote add origin `
Adds a remote repository with the name "origin".- **View Remote Repositories:**
- `git remote -v`
Lists the remote repositories and their URLs.- **Fetch Changes from Remote:**
- `git fetch`
Retrieves new changes from the remote repository without applying them.- **Pull Changes from Remote:**
- `git pull`
Fetches and merges changes from the remote repository.- **Push Changes to Remote:**
- `git push`
Uploads local changes to the remote repository.- **Remove a Remote Repository:**
- `git remote remove origin`
Removes the remote repository named "origin".### **Stashing and Unstashing**
- **Stash Changes:**
- `git stash`
Saves uncommitted changes temporarily and clears the working directory.- **List Stashes:**
- `git stash list`
Lists all stashed changes.- **Apply a Stash:**
- `git stash apply`
Applies the most recent stash to the working directory.- **Drop a Stash:**
- `git stash drop`
Deletes a stash from the stash list.### **Undoing Changes**
- **Unstage a File:**
- `git reset `
Removes a file from the staging area.- **Discard Changes in Working Directory:**
- `git checkout -- `
Discards changes in the working directory for a specific file.- **Revert a Commit:**
- `git revert `
Creates a new commit that undoes the changes made by a previous commit.- **Reset to a Previous Commit:**
- `git reset --hard `
Resets the working directory and staging area to a previous commit, discarding all changes.### **Configuration and Info**
- **View Git Configuration:**
- `git config --list`
Displays the current Git configuration settings.- **Set User Name and Email:**
- `git config --global user.name "Your Name"`
Sets the global username for commits.- `git config --global user.email "[email protected]"`
Sets the global email for commits.- **Show Git Status for a File:**
- `git ls-files`
Lists all files currently tracked by Git.### To Uninit A Repo From Git
- `rmdir /S /Q .git`
- `Remove-Item -Recurse -Force .git`These commands should help you perform a wide range of Git operations effectively.