{"id":28028854,"url":"https://github.com/m-taghizadeh/git-tutorial-for-developers","last_synced_at":"2025-06-12T16:38:49.960Z","repository":{"id":45233873,"uuid":"321383707","full_name":"M-Taghizadeh/Git-tutorial-for-developers","owner":"M-Taghizadeh","description":"Here we learn Git SC and  this repository is for communication with students of Git full course","archived":false,"fork":false,"pushed_at":"2021-12-29T14:14:49.000Z","size":6,"stargazers_count":10,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T07:51:06.967Z","etag":null,"topics":["git","git-tutorial","gitbook","github","github-pages"],"latest_commit_sha":null,"homepage":"https://daneshjooyar.com/learn-git-and-github","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/M-Taghizadeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-14T15:04:12.000Z","updated_at":"2025-04-17T18:46:29.000Z","dependencies_parsed_at":"2022-09-17T04:00:32.913Z","dependency_job_id":null,"html_url":"https://github.com/M-Taghizadeh/Git-tutorial-for-developers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Taghizadeh%2FGit-tutorial-for-developers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Taghizadeh%2FGit-tutorial-for-developers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Taghizadeh%2FGit-tutorial-for-developers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Taghizadeh%2FGit-tutorial-for-developers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/M-Taghizadeh","download_url":"https://codeload.github.com/M-Taghizadeh/Git-tutorial-for-developers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/M-Taghizadeh%2FGit-tutorial-for-developers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258626375,"owners_count":22731770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-tutorial","gitbook","github","github-pages"],"created_at":"2025-05-11T07:32:31.514Z","updated_at":"2025-06-12T16:38:49.921Z","avatar_url":"https://github.com/M-Taghizadeh.png","language":null,"readme":"# Git tutorial for developers\nIn this set of documents, we intend to teach the **Git source control** completely and comprehensively, the training starts from the basic level and covers all the commands that are widely used in the git.\n- This collection has been prepared and collected by [**M.Taghizadeh**](https://github.com/m-taghizadeh) \n- there is no problem with any use by mentioning the source :)\n\n\n## Getting Started\n- [Git installation](#Git-installation)\n- [Git Config](#Git-Config)\n- [Git Phases](#Git-Phases)\n- [Git Commands](#Git-commands)   \n\n\n## Git-installation\n\n- **linux**\n    \u003cp style=\"text-align:right\"\u003e\n    برای نصب این نرم افزار بر روی لینوکس های مبتنی بر دبیان مانند ابونتو دستور زیر را در خط فرمان اجرا کنید\n    : در هر کدارم از پکیج منیجر های توزیع خود میتوانید به راحتی گیت را نصب کنید ، برای مثال در اوبونتو  به شکل زیر \n    \u003c/p\u003e\n\n    ```shell\n    \u003e\u003e sudo apt-get update\n    \u003e\u003e sudo apt-get install git\n    ```\n\n    \u003cp style=\"text-align:right\"\u003e\n    : در توزیع فدورا با یکی از دو دستور زیر   \n    \u003c/p\u003e\n\n    ```shell\n    \u003e\u003e sudo dnf install git\n    یا \n    \u003e\u003e sudo yum install git\n    ```\n\n    \u003cp style=\"text-align:right\"\u003e\n    : در توزیع آرچ لینوکس با پکیج منیجر پکمن  \n    \u003c/p\u003e\n\n    ```shell\n    \u003e\u003e sudo pacman -S git\n    ```\n\u003cbr\u003e\n\n- **mac**\n    \u003cp style=\"text-align:right;\"\u003e\n    راهکارهای گوناگونی برای نصب گیت روی مک وجود دارد اگر پیش از این ایکس کد را نصب کرده باشد (یا ابزار خط فرمان آن را) امکان دارد که گیت به صورت نصب شده روی سیستم او وجود داشته باشد. برای بررسی این موضوع، باید ترمینال را باز و دستور ورژن گیت را وارد کند\n    آسان‌ترین راه برای نصب گیت روی مک، استفاده از نصب کننده گیت (دانلود از خود سایت گیت) است، \n    بنابراین یک نسخه از گیت روی مک بوک ها نصب هست ولی برای نصب جدید ترین نسخه میتوانید از پکیج منیجر های محبوب استفاده کنید مانند\n    \u003c/p\u003e\n    brew package manager\n\u003cbr\u003e\u003cbr\u003e\n\n- **windows**\n    \u003cp style=\"text-align:right; dir:ltr\"\u003e\n    در ویندوز هم به راحتی میتوانیداز طریق پکیج منیجر های ویندوزی نظیر چاکلتی گیت را نصب کنید ولی روش بهتر از طریق نصب کننده گیت ، گیت را نصب کنید با مراجعه کردن به لینک زیر\n\n    https://git-scm.com/downloads\n    \u003c/p\u003e\n\u003cbr\u003e\u003cbr\u003e\n\n- **Verifty**\n    \u003cp style=\"text-align: right;\"\u003e\n    : در ترمینال خود این دستور را بنویسید ، باید بعد از آن ورژن گیت نصب شده خود را مشاهده کنید \n    \u003c/p\u003e\n    \n    ```shell\n    \u003e\u003e git --version\n    ```\n\n\n# Git-Config\n- Local level config\n- Global level config\n- System level config\n\n\n## Git-Phases\n\nThree phases of git :\n1. **Working directory** | **Working tree** | **Working Space** \n2. **Index** | **Stage**\n3. **Repository**\n\nFiles in a repository go through three stages before being under version control with git:\n- **Untracked**: the file exists, but is not part of git's version control\n- **Staged**: the file has been added to git's version control but changes have not been committed\n- **Committed**: the change has been committed\n- git status : is used to understand what stage the files in a repository are at.\n\n\n## Git-commands\n```shell\n# Session 04 : Git installation\n\u003e\u003e git --version # get git version \n\n# Session 05 : Git config \n\u003e\u003e git config --global user.username \"M Taghizadeh\" \n\u003e\u003e git config --global user.email \"example@gmail.com\" \n\u003e\u003e git config --global --list | -L # get list of gloabl configs \n\u003e\u003e git config --global --edit # --edit for edit git configs\n\u003e\u003e git config --local alias.st \"git status\" # add alias for git commands\n\u003e\u003e git config --local alias.gloa \"git log --oneline --all\" \n\n# Session 07 : Create Repository \n\u003e\u003e git init # initial repository\n\u003e\u003e git clone \u003chttps://example.RepoAddress.com\u003e # clone repository from remote\n\n# Session 09 : Deep dive into the phases of Git\n\u003e\u003e git status # show untrackted, modified, staged files\n\u003e\u003e git add filename # add untrackted or modified file to stage\n\u003e\u003e git add . # add all of untrackted or modified file to stage\n\u003e\u003e git add -A # add all of untrackted or modified file to stage\n\u003e\u003e git add --patch # add part of file to staging area\n\u003e\u003e git commit \n\u003e\u003e git commit -m | --message \"comm_msg\" # Commit changes of tracked files to head\n\u003e\u003e git commit -a -m \"comm_msg\" # add all changes of tracked files to staging and commit them.\n\u003e\u003e git commit --amend # amend commit\n\u003e\u003e git commit --amend --no-edit \n\n# Session 10 : Git history\n\u003e\u003e git log # log of commits with date, descriptions and author Name\n\u003e\u003e git log --oneline # summary of git log\n\u003e\u003e git log filename #log of commits with date, descrtions and author Name related to a specific file\n\u003e\u003e git log -p filename # git log with all diff between commits \n\u003e\u003e git show \u003ccommID_10\u003e # show all info + diff HEAD,comm(HEAD-1) \n\u003e\u003e git show \u003ccommID_10\u003e filename # show all info + diff commID9,commID10\n\u003e\u003e git reflog # git reference log\n\u003e\u003e git log --since \"2 days ago\" #show only commits that occur one day ago until now\n\u003e\u003e git log --until \"18:21\" #only shows commits that have occurred until 18:21\n\u003e\u003e git log --author \"Mohammad\" #only shows the commits that user Mohammad has made\n\u003e\u003e git log --since \"Sun Nov 29 17:16:01 2020\" --oneline #only shows commits that have occurred in specific date and time\n\u003e\u003e git log --grep \"add\" #show all commits that have add in their message\n\u003e\u003e git log --stat --summary #show the number of changes per file\n\u003e\u003e git log --all --graph #show all commits of all branchs in tree mode \n\n# Session 11 : Git alias\n\u003e\u003e git config --global alias.gs \"status\" #set shortcuts for git commands for example: gs instead of status\n\u003e\u003e git config --global alias.glo \"log --oneline\"\n\n# Session 12 : Git help\n\u003e\u003e git help \u003cany_commands\u003e #show document related to command\n\n# Session 13 : Git add part of a file to the staging phase\n\u003e\u003e git add --patch | -p \n\n# Session 14 : Git diff \n\u003e\u003e git diff \u003ccommID_1\u003e \u003ccommID_2\u003e filename #show differents between first commit and second commmit in a specific file \n\u003e\u003e git diff --staged filename #show all changes that were staged in a specific file \n\u003e\u003e git diff HEAD #show all changes that were not commited, whether staged or not\n\u003e\u003e git diff #show all changes that were not staged \n\n# Session 15 : Time travel (git checkout, git restore)\n\u003e\u003e git checkout \n\u003e\u003e git checkout -b branch_name commID # checkout in commID and create new branch\n\u003e\u003e git checkout -b branch_name tag_name # checkout in tag_version and create new branch \n\u003e\u003e git restore\n\u003e\u003e git restore index.txt # restore unstaged parts of file to head =\u003e see that with \"git diff\"\n\u003e\u003e git restore --staged index.txt # restore staging parts of file to unstaged =\u003e see that with \"git diff --staged\"\n\u003e\u003e git restore --source HEAD index.txt # restore staging part of file and unstaging part of file =\u003e see that with \"git diff head\"\n\n# Session 16 : Git reset\n\u003e\u003e git reset # by default: --mixed\n\u003e\u003e git reset --soft  \u003ccommID\u003e # reset commits history  \n\u003e\u003e git reset --mixed \u003ccommID\u003e # reset commits history and staging area\n\u003e\u003e git reset --hard  \u003ccommID\u003e # reset commits history and staging area and working directory\n\u003e\u003e git reset --hard  HEAD~2 \n\n# Session 17 : Git revert\n\u003e\u003e git revert \u003ccommitID\u003e\n\n# Session 18 : Git branching\n\u003e\u003e git branch    # list of all local branchs\n\u003e\u003e git branch -r # list of all remote branchs\n\u003e\u003e git branch -a # list of all branchs (local branchs and remote branchs)\n\u003e\u003e git branch -d branch_name\n\u003e\u003e git branch branch_name # create branch\n\u003e\u003e git switch branch_name # switch in branchs\n\u003e\u003e git switch -c branch_name # create and switch branch\n\u003e\u003e git checkout branch_name # switch branch\n\u003e\u003e git checkout -b branch_name # create and switch branch\n\u003e\u003e git checkout -b branch_name commID # create and switch branch on the special commit \n\u003e\u003e git log --oneline --all --graph # log of all commity history on all of branch and show that in graph\n\n# Session 19 : Git merging\n\u003e\u003e git merge\n\u003e\u003e git merge branch_name -m \"merge message\"\n\u003e\u003e git log --oneline --all --graph\n\u003e\u003e git merge --no-ff branch_name\n\n# Session 20 : Git rebase\n\u003e\u003e git rebase master # on branch feature (for example)\n\u003e\u003e git checkout master\n\u003e\u003e git merge feature\n\n# Session 21 : Git merging conflicts\n\u003e\u003e git merge branch_name # we see this message: \"both modified\" conflict\n\u003e\u003e git merge --abort # aborting merge\n\n# Session 22 : Git stash\n\u003e\u003e git stash # tmp storage for saving all of changes in your repo (Tracked files and codes and ...)\n\u003e\u003e git stash save\n\u003e\u003e git stash save \"message\"\n\u003e\u003e git stash save --include-untracked | -u # for Untacked files\n\u003e\u003e git stash show stash@{0}\n\u003e\u003e git stash show -p stash@{0}\n\u003e\u003e git stash pop stash@{0}\n\u003e\u003e git stash apply stash@{0}\n\u003e\u003e git stash drop stash@{1}\n\u003e\u003e git stash clear\n\u003e\u003e git stash list # list of stash\n\u003e\u003e git stash --patch | -p : stash part of files\n\n# Session 23 : Git cherry-pick\n\u003e\u003e git cherry-pick \u003ccommitID\u003e\n\n# Session 24 : Git ignore\n\u003e\u003e git ignore\n\n# Session 25 : Git tag\n\u003e\u003e git tag # list of tags\n\u003e\u003e git tag -l 'v1.4.2.1.*'\n\u003e\u003e git tag v1.0.1 # lightweight tag\n\u003e\u003e git tag -a v1.0.0 -m 'my version v1.0.0' # annotated tags\n\u003e\u003e git tag -s v1.0.0 -m 'my version v1.0.0' # tag by signiture and pgp or gpg key\n\u003e\u003e git tag -d v1.0 v2.0 ... # delete tags\n\u003e\u003e git show v1.0.0\n\u003e\u003e git checkout -b branch_name commID # checkout in commID and create new branch\n\u003e\u003e git checkout -b branch_name tag_name # checkout in tag_version and create new branch\n\n# Session 26 : Git blame\n\u003e\u003e git blame \u003cfilename\u003e \n\u003e\u003e git blame \u003cfilename\u003e -L 1,10 # line 1 to 10\n\u003e\u003e git blame head \u003cfilename\u003e\n\u003e\u003e git blame \u003ccommID\u003e \u003cfilename\u003e  \n\u003e\u003e git blame \u003cbranchName\u003e \u003cfilename\u003e\n\n# Session 27 : Binary search in commits (git bisect)\n\u003e\u003e git bisect # binary search commits\n\u003e\u003e git bisect start\n\u003e\u003e git bisect bad\n\u003e\u003e git bisect good \u003ccommID\u003e # commID from git log of history\n\u003e\u003e git bisect reset # get back to the original branch\n\n# Session 29 : Git remote\n\u003e\u003e git remote # list of remotes in rempository\n\u003e\u003e git remote add remote_name \"http://remote_address.com\" # add new remote\n\u003e\u003e git remote -v # list of remotes  \n\u003e\u003e git remote remove remote_name # remove remote\n\u003e\u003e git remote rename remote_name # rename remote\n\u003e\u003e git remote show remote_name # more info\n\u003e\u003e git push remote_name # \u003cexmp : origin\u003e master\n\u003e\u003e git push remote_name tag_name \n\u003e\u003e git push remote_name --tags\n\u003e\u003e git pull\n\u003e\u003e git fetch\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-taghizadeh%2Fgit-tutorial-for-developers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-taghizadeh%2Fgit-tutorial-for-developers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-taghizadeh%2Fgit-tutorial-for-developers/lists"}