{"id":22662799,"url":"https://github.com/christmaskris/gitsheet","last_synced_at":"2025-10-14T23:41:54.398Z","repository":{"id":264824455,"uuid":"893314101","full_name":"ChristmasKris/GitSheet","owner":"ChristmasKris","description":"A beginner-friendly guide to Git, GitHub, and terminal commands. Includes essential workflows, command references and tips.","archived":false,"fork":false,"pushed_at":"2025-06-08T13:56:52.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T14:36:53.937Z","etag":null,"topics":["bash","documentation","git","tutorial"],"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/ChristmasKris.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-24T05:11:48.000Z","updated_at":"2025-06-08T13:56:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"5faac194-6c70-43e6-92e6-610a6999b7c2","html_url":"https://github.com/ChristmasKris/GitSheet","commit_stats":null,"previous_names":["christmaskris/gitsheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ChristmasKris/GitSheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristmasKris%2FGitSheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristmasKris%2FGitSheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristmasKris%2FGitSheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristmasKris%2FGitSheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChristmasKris","download_url":"https://codeload.github.com/ChristmasKris/GitSheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristmasKris%2FGitSheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275232279,"owners_count":25428224,"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","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bash","documentation","git","tutorial"],"created_at":"2024-12-09T12:15:33.344Z","updated_at":"2025-10-14T23:41:49.344Z","avatar_url":"https://github.com/ChristmasKris.png","language":null,"readme":"# GitSheet: A Comprehensive Git \u0026 Terminal Command Reference\n\n## What is GitSheet?\n\nGitSheet is a curated, easy-to-navigate reference for essential Git, GitHub, and terminal commands. It’s designed to help developers quickly find the right command for common version control and workflow tasks, from repository setup to advanced branching and deployment. The project also includes practical tutorials for real-world scenarios, such as SSH key management and live deployment.\n\n## Why I Built This Project\n\nAs a developer, I often found myself searching for the same Git commands and best practices, especially when switching between projects or onboarding new team members. I built GitSheet to solve this problem: to have a single, reliable resource that covers not just the commands, but also the context and reasoning behind them. It’s meant to save time, reduce mistakes, and help others ramp up quickly with Git and terminal workflows.\n\n## Technologies \u0026 Tools Used\n\n- **Markdown** for clear, portable documentation\n- **Git** and **GitHub** for version control and collaboration\n- **Shell scripting** for advanced configuration and automation examples\n- **Nano** and **VS Code** as featured editors in workflow examples\n\n## Key Features \u0026 Code Examples\n\n### 1. Step-by-Step Tutorials\n\nThe project includes detailed, copy-paste-ready tutorials for common and advanced tasks. For example, generating SSH keys for GitHub:\n\n```shell\nssh-keygen -t ed25519 -C \"your-email@gmail.com\"\neval \"$(ssh-agent -s)\"\nssh-add ~/.ssh/id_ed25519\ncat ~/.ssh/id_ed25519.pub\n```\n\n### 2. Command Reference with Explanations\n\nEvery major Git operation is covered, with concise explanations and real command examples:\n\n```shell\ngit clone https://github.com/username/repository.git .\ngit status\ngit branch\ngit checkout -b new-branch-name\ngit add .\ngit commit -m \"Initial commit\"\ngit push -u origin master\n```\n\n### 3. Advanced Workflow Tips\n\nThe documentation goes beyond basics, including deployment and branch management:\n\n```shell\n# Initialize a bare repository for live deployment\nssh user@your-server-ip\ncd /home/username/\ngit init --bare repositoryName.git\n\n# Example post-receive hook for auto-deployment\n#!/bin/bash\nGIT_WORK_TREE=/home/username/public_html\nexport GIT_WORK_TREE\ngit checkout -f master -- . ':!.gitignore'\n```\n\n### 4. Editor Shortcuts and Customization\n\nQuick reference for using Nano and setting up your preferred editor:\n\n```shell\ngit config --global core.editor \"code --wait\"\ngit config --global core.editor \"nano\"\n```\n\n### 5. Shell Prompt Customization\n\nFor power users, GitSheet includes shell prompt customization to show the current repo and branch:\n\n```shell\nfunction parse_git_repo {\n\tgit rev-parse --show-toplevel 2\u003e/dev/null | xargs basename\n}\n\nfunction parse_git_branch {\n\tgit branch 2\u003e/dev/null | sed -n '/\\* /s///p'\n}\n\nPS1=\"$(if git rev-parse --is-inside-work-tree \u0026\u003e/dev/null; then echo \\\"$(parse_git_repo)/\\033[0;36m$(parse_git_branch)\\033[0m\\\"; else echo \\\"\\w\\\"; fi)\u003e \"\n```\n\n## What Have I Learned?\n\nBuilding GitSheet deepened my understanding of Git’s inner workings and the value of clear, actionable documentation. I learned how to distill complex workflows into simple, repeatable steps, and how to anticipate the needs of both beginners and experienced developers. This project also reinforced the importance of automation and customization in developer productivity.\n\nIf you’d like to know more about the project, feel free to reach out!\n\n# GitHub/Git/Terminal commands\n\n- [Tutorials](#tutorials \"Go to section\")\n- [Navigation](#navigation \"Go to section\")\n- [Repository](#repository \"Go to section\")\n- [Branch](#branch \"Go to section\")\n- [Commit](#commit \"Go to section\")\n- [Staging](#staging \"Go to section\")\n- [Stash](#stash \"Go to section\")\n- [Nano text editor](#nano-text-editor \"Go to section\")\n- [Defaults](#defaults \"Go to section\")\n\n## Tutorials\n\n**How to generate SSH keys on your pc for secure authentication with GitHub?**\n\n1. Navigate to your SSH directory like so: ```cd ~/.ssh```.\n2. Remove any existing ssh keys which are the ```id_*******``` and ```id_*******.pub``` or ```id_rsa``` and ```id_rsa.pub``` files inside of the .ssh directory.\n3. Generate a new SSH key using the Ed25519 algorithm like so: ```ssh-keygen -t ed25519 -C \"your-email@gmail.com\"```.\n4. When prompted to \"Enter a file in which to save the key,\" press Enter to accept the default location which is ```(~/.ssh/id_ed25519)```.\n5. When prompted to \"Enter passphrase,\" you can either enter a secure passphrase or leave it empty for no passphrase. Leaving it empty is easier.\n6. Start the SSH agent in the background like so: ```eval \"$(ssh-agent -s)\"```.\n7. Add your new SSH key to the SSH agent like so: ```ssh-add ~/.ssh/id_ed25519```.\n8. Add the SSH key to your GitHub account by viewing your public key like so ```cat ~/.ssh/id_ed25519.pub```.\n9. Log in to your GitHub account in your browser.\n10. Go to settings \u003e SSH and GPG keys \u003e New SSH key.\n11. Give the key any title that you prefer.\n12. Pick authentication as the key's type in the dropdown.\n13. Paste your key without the last space and the e-mail address part which will look something like: ```ssh-ed25519 your-key-will-be-here your-email@gmail.com```.\n14. Test the SSH connection like so ```ssh -T git@github.com```.\n15. Then you should see a message like ```Hi username! You've successfully authenticated, but GitHub does not provide shell access.```.\n16. Done.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to generate SSH keys on your pc for secure authentication with your webhost?**\n\nIf you already have an SSH key for GitHub for example, you can reuse that public key for your webhost aswell.\n\n1. Execute the following command: ```ssh-keygen -t rsa -b 4096 -C \"yourEmail@gmail.com\" -f ~/.ssh/id_rsa_custom_name```.\n2. Press enter to accept the default file location.\n3. You can enter a password for extra protection if you would like to.\n4. Add the SSH key to the SSH agent by running the following command: ```eval \"$(ssh-agent -s)\"```.\n5. Add your SSH private key to the agent by running the following command: ```ssh-add ~/.ssh/id_rsa_custom_name```.\n6. Add the public key ```~/.ssh/id_rsa_custom_name.pub``` to your webhost.\u003cbr\u003e\nIf you want to create a custom profile for easier SSH login, then follow steps 7 and 8, otherwise skip these steps.\n7. Edit the SSH config file with the following command: ```nano ~/.ssh/config``` and paste the following code. Replace what's necessary with your credentials.\n```\nHost yourdomain.com\n\tHostName yourdomain.com\n\tUser yourCPanelUsername\n\tPort 0000\n\tIdentityFile ~/.ssh/id_rsa_custom_name\n```\n8. Now you can SSH into your webhost by running the following command: ```ssh yourdomain.com```.\n9. Done, you can now SSH into your webhost with an SSH key and without a password by starting an SSH connection your usual way ```ssh -p port username@yourdomain.com```.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to Initialize a GitHub Repository for an Existing Project \u0026 create a .gitignore?**\n\n1. Create a new repository on GitHub without a README.md.\n2. Initialize Git in your project's local directory with ```git init```.\n3. Temporarily move any config or environment variables outside of your project if you would not like these to be uploaded aswell.\n4. Create a ```.gitignore``` file in your project's local main directory.\n5. Include all paths/files in this file that you would like Git to ignore so that they stay offline like so:\n\t```shell\n\t.env\n\tphp/config.php\n\tjs/general/data.js\n\t```\n6. Stage your files with ```git add .```.\n7. Commit your files with ```git commit -m \"Initial commit\"```.\n8. Link your local repository to your GitHub repository and replace ```username``` with your GitHub username and ```repository-name``` with your online repository's name. Run the following command: ```git remote add origin https://github.com/username/repository-name.git```.\n9. Push your local commits to GitHub with ```git push -u origin master```. You can name your main branch anything, in this case it's ```master```.\n10. Put your ignored files back into your local project and they will stay offline.\n11. Done.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to move your progress/changes into a new branch?**\n\n1. With ```git stash``` you can temporarily \"stash\" your changes from your current branch.\n2. Then with ```git stash branch new-branch-name``` you can put the changes into a new branch and the stash will get deleted automatically.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to set up production on a web host for live deployment?**\n\n1. SSH into your live server.\n2. In your ```home/username/``` directory, create a folder where your repository will be located in. The name of this folder can be anything. (do not put the folder into public_html or any web-accessible directory)\n3. Then go into this new folder and run the following command to initialize a bare repository: ```git init --bare repositoryName.git```. The name of this repository can be anything.\n4. Go into your repository and then go into the generated ```hooks``` folder.\n5. Run the following command: ```nano post-receive```. This will create a file called ```post-receive```. This file will not have or need an extension.\n6. Paste the code below into the file and replace ```/home/username/public_html``` with the path to your web-accessible directory. Then save and exit the file. This also excludes the ```.gitignore``` file from being uploaded to your web-accessible directory.\n\t```\n\t#!/bin/bash\n\tGIT_WORK_TREE=/home/username/public_html\n\texport GIT_WORK_TREE\n\tgit checkout -f master -- . ':!.gitignore'\n\t```\n7. Make the file executable by running the following command: ```chmod +x post-receive```. You may now close the connection to your server.\n8. Open your local terminal and navigate to your local project directory.\n9. Run the following command to add the live repository to your local project: ```git remote add production ssh://user@your-server-ip:port/home/username/repo/repositoryName.git```. Replace what's necessary with your credentials.\n10. To upload your master branch to your live website, run the following command: ```git push production master```.\n11. Done.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to initialize a folder with an existing remote repository?**\n\n1. Use [```git clone```](#cloneCommand \"Go to command\") to clone a repository into your current folder by copying their SSH url which looks something like ```git@github.com:username/repository.git```.\n2. Done.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to upload changes from your current branch to your remote repository?**\n\n1. Update your local branch with the remote master branch with [```git pull```](#pullCommand \"Go to command\") to be able to resolve any conflicts that may occur locally instead of remotely.\n2. Make all your changes here and proceed when done with everything for the upcoming commit.\n3. Stage the changes with [```git add```](#addCommand \"Go to command\").\n4. Commit the changes with [```git commit```](#commitCommand \"Go to command\").\n5. Push the changes with [```git push```](#pushCommand \"Go to command\").\n6. If you want to do the next steps through the terminal then continue here, otherwise finish it on GitHub.\n7. Go into the master branch.\n8. Pull remote master branch into your local master branch with [```git pull```](#pullCommand \"Go to command\").\n9. Merge branch into master if everything is good with [```git merge```](#mergeCommand \"Go to command\").\n10. Delete merged branch locally with [```git branch -d```](#deleteLocalBranchCommand \"Go to command\") and remotely with [```git push origin --delete```](#deleteRemoteBranchCommand \"Go to command\").\n11. Create a pull request on GitHub to merge your current branch into the remote main (or master) branch.\n12. Done.\n\u003cbr\u003e\u003cbr\u003e\n\n**How to delete a file from the local \u0026 remote repository?**\n\n1. Delete the file with [```git rm```](#deleteRemoteCommand \"Go to command\").\n2. Commit the changes with [```git commit```](#commitCommand \"Go to command\").\n3. Push the changes with [```git push```](#pushCommand \"Go to command\").\n4. Done.\n\n## Navigation\n\n\u003cspan id=\"cloneCommand\"/\u003e\n\nClone a remote repository into your local folder. The ```.``` at the end specifies the current directory as the destination for the cloned repository instead of creating another folder inside of the current directory.\n\n```shell\ngit clone https://github.com/username/repository.git .\n```\n\nView settings.\n\n```shell\ngit config --list\n```\n\nMove to directory.\n\n```shell\ncd ./myDirectory\n```\n\nEdit in VS Code.\n\n```shell\ncode ./myFile.txt\n```\n\nEdit in terminal.\n\n```shell\nnano ./myFile.txt\n```\n\nCreate a directory\n\n```shell\nmkdir myFolder\n```\n\nCreate a file\n\n```shell\ntouch myFile.txt\n```\n\nCheck status of staged files.\n\n```shell\ngit status\n```\n\nList all branches and see which you are currently one.\n\n```shell\ngit branch\n```\n\nList all remote branches.\n\n```shell\ngit branch -r\n```\n\nSwitch to a branch.\n\n```shell\ngit checkout branch-name\n```\n\nView existing remote repositories.\n\n```shell\ngit remote -v\n```\n\nView the current directory.\n\n```shell\npwd\n```\n\nView the current directory's contents.\n\n```shell\nls\n```\n\nGo into the desktop folder in git-bash.\n\n```shell\ncd ~/Desktop\n```\n\n\u003cspan id=\"deleteRemoteCommand\"/\u003e\n\nDelete a file from repository\n\n```shell\ngit rm ./myFile.txt\n```\n\nDelete a file from local system\n\n```shell\nrm ./myFile.txt\n```\n\n## Repository\n\nFetch latest changes from remote repository.\n\n```shell\ngit fetch\n```\n\nLink your local repository to a remote repository without cloning the remote one.\n\n```shell\ngit remote add origin remote-repository-url\n```\n\n\u003cspan id=\"pushCommand\"/\u003e\n\nPush changes from branch to remote repository, use ```-u``` flag when command has not been used yet for the local branch to track the remote branch.\n\n```shell\ngit push -u origin branch-name\n```\n\n```shell\ngit push origin branch-name\n```\n\n\u003cspan id=\"pullCommand\"/\u003e\n\nUpdate local branch (recommended to do this regularly) with changes from remote repository without altering files that you have worked in locally. Then merge the fetched changes into your local branch (see 2nd command). Or do it all in one command (see 3rd command) or (see 4th command) if 3rd command used already at least once to track remote branch.\n\n```shell\ngit fetch origin\n```\n\n```shell\ngit merge origin/branch-name\n```\n\n```shell\ngit pull origin branch-name\n```\n\n```shell\ngit pull\n```\n\n## Branch\n\nCreate and switch to a new branch.\n\n```shell\ngit checkout -b new-branch-name\n```\n\nView differences between 2 branches.\n\n```shell\ngit diff branch-name1 branch-name2\n```\n\n\u003cspan id=\"mergeCommand\"/\u003e\n\nMerge another branch into the current branch.\n\n```shell\ngit merge other-branch-name\n```\n\n\u003cspan id=\"deleteLocalBranchCommand\"/\u003e\n\nDelete local branch if fully merged. Use ```-D``` (2nd command) to force delete even if it has not been merged.\n\n```shell\ngit branch -d branch-name\n```\n\n```shell\ngit branch -D branch-name\n```\n\n\u003cspan id=\"deleteRemoteBranchCommand\"/\u003e\n\nDelete remote branch.\n\n```shell\ngit push origin --delete branch-name\n```\n\n## Commit\n\n\u003cspan id=\"addCommand\"/\u003e\n\nAdd all files in current directory and subdirectories to next commit.\n\n```shell\ngit add .\n```\n\nAdd a specific file to next commit.\n\n```shell\ngit add ./myFile.txt\n```\n\n\u003cspan id=\"commitCommand\"/\u003e\n\nCommit staged files to local repository and include short message. Or include long message (see 2nd command).\n\n```shell\ngit commit -m \"Brief description comes here\"\n```\n\n```shell\ngit commit\n```\n\nView commit history. Or view them on one line (see 2nd command).\n\n```shell\ngit log\n```\n\n```shell\ngit log --oneline\n```\n\nRevert changes in a specific file to last committed state.\n\n```shell\ngit restore ./filename.txt\n```\n\nRevert all changes in the current directory to last committed state.\n\n```shell\ngit restore .\n```\n\nRevert the most recent commit that has been made already.\n\n```shell\ngit revert HEAD\n```\n\nRevert a specific commit.\n\n```shell\ngit revert commit-hash-here\n```\n\nDelete all recent local commits.\n\n```shell\ngit reset --hard origin/branch_name\n```\n\nView commit log.\n\n```shell\ngit log\n```\n\nExit commit log.\n\n```shell\nQ\n```\n\n## Staging\n\nView differences between local worked in files and the staging area.\n\n```shell\ngit diff\n```\n\nView changes that are staged for the next commit.\n\n```shell\ngit diff --staged\n```\n\nUnstage a specific file.\n\n```shell\ngit reset HEAD ./filename.txt\n```\n\nUnstage all files.\n\n```shell\ngit reset HEAD\n```\n\n## Stash\n\nStash current changes, also staged changes and return directory to clean state.\n\n```shell\ngit stash\n```\n\nList all stashed changes.\n\n```shell\ngit stash list\n```\n\nApply most recent stash.\n\n```shell\ngit stash apply\n```\n\nApply and remove most recent stash.\n\n```shell\ngit stash pop\n```\n\nApply a specific stash.\n\n```shell\ngit stash apply stash@{stash number}\n```\n\nApply and remove a specific stash.\n\n```shell\ngit stash pop stash@{stash number}\n```\n\nDelete a specific stash.\n\n```shell\ngit stash drop stash@{stash number}\n```\n\nDelete all stashes.\n\n```shell\ngit stash clear\n```\n\n## Nano text editor\n\nEdit/create a file.\n\n```shell\nnano ./myFile.txt\n```\n\nDisplay help menu.\n\n```\nCTRL + G\n```\n\nSave file.\n\n```\nCTRL + O\n```\n\nExit file (prompt to save/discard changes will pop up).\n\n```\nCTRL + X\n```\n\n## Defaults\n\nSet default text editor to VS Code and wait until editor window closed to proceed.\n\n```shell\ngit config --global core.editor \"code --wait\"\n```\n\nSet default text editor to nano (terminal editor).\n\n```shell\ngit config --global core.editor \"nano\"\n```\n\nView default text editor configuration.\n\n```shell\ngit config --global core.editor\n```\n\nShow branch in terminal PS (process status). Paste the following into the ```.bashrc``` file. This will change the PS in non-git directories to the current path like so: ```~/Desktop\u003e``` and in git directories like so: ```repository/branch-name\u003e```. It will also make the branch name cyan colored.\n\n```shell\nfunction parse_git_repo {\n\tgit rev-parse --show-toplevel 2\u003e/dev/null | xargs basename\n}\n\nfunction parse_git_branch {\n\tgit branch 2\u003e/dev/null | sed -n '/\\* /s///p'\n}\n\nPS1=\"\\$(if git rev-parse --is-inside-work-tree \u0026\u003e/dev/null; then echo \\\"\\$(parse_git_repo)/\\[\\033[0;36m\\]\\$(parse_git_branch)\\[\\033[0m\\]\\\"; else echo \\\"\\w\\\"; fi)\u003e \"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristmaskris%2Fgitsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristmaskris%2Fgitsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristmaskris%2Fgitsheet/lists"}