{"id":20605066,"url":"https://github.com/abdullah-ch/git-cheat-sheet","last_synced_at":"2025-03-06T16:54:13.123Z","repository":{"id":56485534,"uuid":"302947283","full_name":"abdullah-ch/Git-Cheat-Sheet","owner":"abdullah-ch","description":"A Cheat Sheet which covers commands which do most of the work you want to do with git.","archived":false,"fork":false,"pushed_at":"2023-08-28T07:25:17.000Z","size":6767,"stargazers_count":13,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T02:24:04.118Z","etag":null,"topics":["git","github","hacktoberfest"],"latest_commit_sha":null,"homepage":"","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/abdullah-ch.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-10T16:46:44.000Z","updated_at":"2024-06-28T21:08:30.000Z","dependencies_parsed_at":"2024-11-16T09:36:52.112Z","dependency_job_id":null,"html_url":"https://github.com/abdullah-ch/Git-Cheat-Sheet","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/abdullah-ch%2FGit-Cheat-Sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdullah-ch%2FGit-Cheat-Sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdullah-ch%2FGit-Cheat-Sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdullah-ch%2FGit-Cheat-Sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abdullah-ch","download_url":"https://codeload.github.com/abdullah-ch/Git-Cheat-Sheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242250935,"owners_count":20096895,"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","github","hacktoberfest"],"created_at":"2024-11-16T09:26:21.389Z","updated_at":"2025-03-06T16:54:13.094Z","avatar_url":"https://github.com/abdullah-ch.png","language":null,"readme":"# Git-Cheat-Sheet\n## Git Bash Terminal  \n[Download the Terminal from here](https://git-scm.com/downloads)  \n\n### 0-\u003e Configuring the Bash Terminal\n`git config --global user.name “Your Name”`    \n`git config --global user.email “Youremail@anything.com”`    \n### 1-\u003e Creating a Repository\n`git init  `     \n`git remote add origin [repoLink]   `  \n#### Origin works like a pointer to the repoLink, making the referencing easier \n`git remote -v  `   \n`git add .   `  \n`git commit -m \"[your message]\"  `   \n`git push origin [branchName]  `  \n ### 2-\u003e Creating a Pull Request\n#### Fork the desired Repo    \n`git clone [forkedRepoLink]`    \n#### Do your Contribution  \n`git add .`  \n`git commit -m \"your message\"`  \n`git push origin [branchName]`  \n### 3-\u003e Getting Updates from the Main Repo to Your Forked Repo  \n`git remote add upstream [originalRepoLink]`  \n#### Upstream Acts as a pointer towards the Main Repo's remote  \n`git pull upstream master`  \n#### Changes from the Main remote are pulled Locally  \n`git push origin`    \n#### Changes are pushed to the Forked Remote Repo !  \n### 4-\u003e Get Information about Your Commits\n`git log --pretty=oneline`  \n### 5-\u003e Move to Your Desired Commit or Branch\n`git checkout hash/branch` \n### 6-\u003e Undoing Staged Files  \n`git reset HEAD \u003cfile\u003e`  \n#### where HEAD can be your Hash number (First Four Digits will do fine) or your Branch Name  \n### 7-\u003e Undoing Commited Files\n`git revert HEAD`  \n####  where HEAD can be your Hash number (First Four Digits will do fine) or your Branch Name  \n### 8-\u003e Pulling changes Locally from a Remote Repo\n`git pull origin [branchName]`  \n#### Where the origin can be replaced by the respective remote pointer.  \n### 9-\u003e View the state of your Staging Area and Changes in your Directory\n`git status`    \n### 10-\u003e View the History of your Commits along with their Hash Codes of the Repo  \n`git log --pretty=oneline`  \n\n### 11-\u003e View the difference between branches    \n`git diff --color thatBranchNameYouWantToCompare`    \n\n### 12-\u003e Delete a branch remotely    \n`git push origin --delete \u003cbranch\u003e`  \n\n### 13-\u003e Unstage your changes\n`git reset`\n\n### 13-\u003e Unstage your changes and reset the working directory\n`git reset --hard`\n\n### 13-\u003e Revert back to the last commit (Undo Last Commit)  \n`git reset HEAD~1` \n\n**OR**  \n\n`git revert [last-commit-hash]` (This will create a new commit for reverted changes)\n\n\n## Some Questions and Answers !!\n### Q1-\u003e I have pushed some commit/s that I shouldn't. Now, I want to remove them locally and remotely. I want my History on Github to be cleared of those wrong commits. What should I do ??  \n#### First, see your commits, understand them and select how many commit/s you want to delete.  \n`git log --pretty=oneline`    \n#### Now, choose a number of commits you want to change i.e lets say recent 4 commits and delete them locally. Type the following command and simply remove the commits in your text editor(simply delete the line) and save the file  \n`git rebase -i HEAD~4`    \n#### Check your commit tree by using git log command and become sure that your commits have been removed locally. Once, you're certain, push the remaining commits.\n`git push origin branchName --force`  \n#### Your History will be altered and the commits will be removed remotely as well as locally    \n### Q2-\u003e How can I pull a certain branch from GitHub ?\n`git fetch origin`  \n`git branch -f [branchName]/[branchName]`  \n`git checkout branchName`  \n#### This command will create a branch of the same name of the remote branch that you're going to pull from   \n  \n\n  \n\n \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdullah-ch%2Fgit-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdullah-ch%2Fgit-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdullah-ch%2Fgit-cheat-sheet/lists"}