ورقة غش Git
مرجع تفاعلي لأوامر Git. ابحث وصفّ حسب الفئة لإيجاد الأمر الصحيح بسرعة.
git config --global user.name "Your Name"Set your username globally
git config --global user.email "email@example.com"Set your email globally
git config --listList all Git configuration
git config --global core.editor "code --wait"Set VS Code as default editor
git initInitialize a new Git repository
git clone <url>Clone a repository
Example: git clone https://github.com/user/repo.git
git statusShow working tree status
git add <file>Stage a specific file
Example: git add index.js
git add .Stage all changes
git add -pInteractively stage changes
git commit -m "message"Commit staged changes
Example: git commit -m "Add feature"
git commit -am "message"Stage and commit all tracked files
git commit --amendModify the last commit
git commit --amend --no-editAmend without changing message
git branchList local branches
git branch -aList all branches (local + remote)
git branch <name>Create a new branch
Example: git branch feature-login
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to new branch
Example: git checkout -b feature-login
git switch <branch>Switch to a branch (newer syntax)
git switch -c <branch>Create and switch (newer syntax)
git branch -d <branch>Delete a merged branch
git branch -D <branch>Force delete a branch
git branch -m <old> <new>Rename a branch
git merge <branch>Merge branch into current branch
Example: git merge feature-login
git merge --no-ff <branch>Merge with merge commit
git merge --abortAbort a merge in progress
git rebase <branch>Rebase current branch onto branch
git rebase --abortAbort a rebase in progress
git rebase --continueContinue after resolving conflicts
git remote -vList remote repositories
git remote add origin <url>Add a remote repository
git pushPush to remote
git push -u origin <branch>Push and set upstream
git push --forceForce push (use with caution!)
git pullFetch and merge from remote
git fetchFetch from remote without merging
git fetch --pruneFetch and remove deleted remote branches
git reset <file>Unstage a file
git reset --soft HEAD~1Undo last commit, keep changes staged
git reset --mixed HEAD~1Undo last commit, keep changes unstaged
git reset --hard HEAD~1Undo last commit, discard changes
git checkout -- <file>Discard changes in file
git restore <file>Discard changes (newer syntax)
git restore --staged <file>Unstage a file (newer syntax)
git revert <commit>Create commit that undoes changes
git clean -fdRemove untracked files and directories
git stashStash current changes
git stash save "message"Stash with a message
git stash listList all stashes
git stash popApply and remove last stash
git stash applyApply last stash without removing
git stash dropRemove last stash
git stash clearRemove all stashes
git logShow commit history
git log --onelineShow compact commit history
git log --graphShow history with branch graph
git log -p <file>Show file history with diffs
git diffShow unstaged changes
git diff --stagedShow staged changes
git diff <branch1>..<branch2>Compare two branches
git show <commit>Show a specific commit
git blame <file>Show who changed each line
git tagList all tags
git tag <name>Create a lightweight tag
Example: git tag v1.0.0
git tag -a <name> -m "message"Create an annotated tag
git push --tagsPush all tags to remote
git tag -d <name>Delete a local tag
Quick Tips:
- • Use
git statusfrequently to see current state - • Create feature branches with
git checkout -b feature-name - • Use
git stashto temporarily save work - • Always review changes with
git diffbefore committing
Git Version Control - التفاصيل التقنية
Git is the most widely used version control system. Understanding Git commands helps you manage code history, collaborate with teams, and recover from mistakes. Start with basic commands and gradually learn advanced features.
بديل سطر الأوامر
# Essential workflow git add . git commit -m "message" git push origin main # Undo last commit git reset --soft HEAD~1