{"id":17991005,"url":"https://github.com/oleksiyrudenko/dev-env-git","last_synced_at":"2025-03-25T23:31:54.429Z","repository":{"id":85274065,"uuid":"194419530","full_name":"OleksiyRudenko/dev-env-git","owner":"OleksiyRudenko","description":"Basic git setup","archived":false,"fork":false,"pushed_at":"2024-12-10T16:02:03.000Z","size":111,"stargazers_count":10,"open_issues_count":41,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-17T01:37:01.641Z","etag":null,"topics":["cli-enhancements","developer-tools","environment-configuration","git","tweaking-git"],"latest_commit_sha":null,"homepage":"https://oleksiyrudenko.github.io/dev-env-git/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OleksiyRudenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-06-29T15:19:11.000Z","updated_at":"2024-12-10T16:02:07.000Z","dependencies_parsed_at":"2024-09-14T05:33:02.004Z","dependency_job_id":"4178997a-f971-4210-ab2a-018f1315956b","html_url":"https://github.com/OleksiyRudenko/dev-env-git","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/OleksiyRudenko%2Fdev-env-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OleksiyRudenko%2Fdev-env-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OleksiyRudenko%2Fdev-env-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OleksiyRudenko%2Fdev-env-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OleksiyRudenko","download_url":"https://codeload.github.com/OleksiyRudenko/dev-env-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245561866,"owners_count":20635828,"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":["cli-enhancements","developer-tools","environment-configuration","git","tweaking-git"],"created_at":"2024-10-29T19:19:52.287Z","updated_at":"2025-03-25T23:31:49.410Z","avatar_url":"https://github.com/OleksiyRudenko.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Entry level: beginner](https://img.shields.io/badge/Entry%20level-beginner-brightgreen.svg)\n\n# Development Environment Helpers: git\n\nThis repo contains opinionated recommendations and suggestions\nas to the tools that many frontend developers (especially beginners)\nwill find useful.\n\nIf you are a beginner frontend developer you may also find\n[`dev-env-frontend`](https://github.com/OleksiyRudenko/dev-env-frontend)\nrecommendations useful.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n## Table of Contents\n\n- [Intro](#intro)\n- [Basic setup](#basic-setup)\n  - [Credentials manager](#credentials-manager)\n- [Friendly git editor](#friendly-git-editor)\n  - [What might go wrong?](#what-might-go-wrong)\n- [Git Helpers](#git-helpers)\n  - [CLI Enhancements](#cli-enhancements)\n  - [Git Aliases](#git-aliases)\n  - [Git Flow](#git-flow)\n    - [Basic flow](#basic-flow)\n    - [Git Town](#git-town)\n- [More resources on tweaking git](#more-resources-on-tweaking-git)\n- [Advanced](#advanced)\n  - [Subrepo](#subrepo)\n- [IDE minimal tweak](#ide-minimal-tweak)\n  - [`.editorconfig`](#editorconfig)\n- [Issues?](#issues)\n- [Contributors](#contributors)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- generated with [DocToc](https://github.com/thlorenz/doctoc) --\u003e\n\n## Intro\n\n[This repo](https://github.com/OleksiyRudenko/dev-env-git) contains scripts that make git users'\nand project maintainers' life easier.\n\nAll scripts are optional. It is recommended that you look\ninto the script of your choice before using it.\nSome scripts require you to patch e.g. file path before they\ncan be efficiently invoked.\n\nSome tools/scripts are specific to Windows OS (as denoted).\nUnder Windows scripts are intended to get launched under\ne.g. Git Bash that comes bundled with git distribution.\nIt would be available from file explorer context menu.\n\nIn terminal navigate to this project directory and execute\n`chmod u=rwx *.sh` to make shell scripts executable.\n\nRemember to precede script with explicit path, e.g. `./script.sh`\n\n## Basic setup\n\nGet registered with [github.com](https://github.com/).\n\nInstall [git](https://git-scm.com/downloads).\n\n**Notes for Windows users**\n\u003e When prompted to choose an editor\n\u003e it is recommended that you opt for `Notepad++` (a GUI enabled\n\u003e editor) or `Nano` (non-GUI, yet friendlier to beginners than\n\u003e `vim`).\n\u003e When prompted for extra options enable file system caching.\n\nOpen Terminal (Git Bash under Windows). The most of the instructions\nbelow are to be completed in Terminal.\n\n\u003cdetails\u003e\u003csummary\u003eA note for Windows users (click to expand)\u003c/summary\u003e\nDid you know you can open git bash from File Explorer?\nLocate your project (or just e.g. any directory in your file system)\nin File Explorer, right click within explorer window\nto open context menu and select \"Git Bash Here\" option.\n\nBash will get opened in context of your project.\n\n![git bash context menu](./media/git-bash-context-menu.png)\n\u003c/details\u003e\n\n**All OS**\n\nExecute following commands to have your git identity configured.\nReplace **\"John Doe\"** with your real name (obey quotes)\nand **999999+johndoe@users.noreply.github.com** with the email GitHub suggests\nin your settings https://github.com/settings/emails to protect\nyour real email address from parsing.\n```\ngit config --global user.name \"John Doe\"\ngit config --global user.email 999999+johndoe@users.noreply.github.com\n```\n\n_Note!_ Copy-paste + edit are your best friends most of the time.\n\nNavigate to the location you are going to have your development projects in.\nYour home directory is a good point to start at.\nYou can get to your home directory by executing `cd ~/` command in Terminal.\n\nNext execute the following commands one-by-one to have all required\nfiles from this repository on your machine:\n```\ngit clone https://github.com/OleksiyRudenko/dev-env-git.git\ncd dev-env-git\n```\n\nExecute `chmod u=rwx *.sh` to make shell scripts executable.\n\nYou may close Terminal eventually.\nYou can get back to this project at any time by executing the following\ncommand in terminal to catch up:\n```\ncd ~/dev-env-git\n```\n\n\u003cdetails\u003e\u003csummary\u003eA recommendation on projects organization\u003c/summary\u003e\nConsider using the projects directory structure that reflects\nyour accounts on potentially multiple repo hosting platforms, both\nyour personal and under various organizations you may be a part to.\n\n```bash\n/dev\n |-- kottans.gh  # projects that are hosted under Kottans org on GitHub\n |-- or.gh       # projects that are hosted under Oleksiy Rudenko's acc on GitHub\n \\-- or.gl       # projects that are hosted under Oleksiy Rudenko's acc on GitLab\n```\n\nThis way you will also be able to fine tune git per directory tree.\n(Paths below are in Windows notation).\n\n```editorconfig\n# ~/.gitconfig\n[user]\n    name = \"John Doe\"\n\n[includeIf \"gitdir:C:/dev/or.gh/**\"]\n    path = ~/.gitconfig.dev.or.gh.gitconfig\n\n[includeIf \"gitdir:C:/dev/or.gl/**\"]\n    path = ~/.gitconfig.dev.or.gl.gitconfig\n\n# ~/.gitconfig.dev.or.gh.gitconfig\n[user]\n    email = 999999+johndoe@users.noreply.github.com\"\n\n# ~/.gitconfig.dev.or.gl.gitconfig\n[user]\n    email = johndoe@noreply.gitlab.com\"\n```\n\n\u003c/details\u003e\n\n### Credentials manager\n\nCredential manager helps to avoid authorization phase at\nevery operation on remote repo with git.\n\n**Windows**:\nInstall [Git Credential Manager for Windows](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases).\nFor downloads unfold and check **Assets** subsection below latest release\n**Change Log**.\n\n**MacOS**: OSX keychain store is used by default, no need to install anything.\nJust tell Git to use the KeyChain to store your credentials:\n\n`git config --global credential.helper osxkeychain`\n\n**Linux Mint/Ubuntu**\n\nExecute `./credential-manager-linux.sh` in Terminal:\n\nIf any command fails try googling the error message to fix the issue.\n\nAlternatively, for Linux you may try\n[Git Credential Manager from Microsoft](https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux/blob/master/Install.md#installing-on-linux-using-rpm-recommended).\n\n**Success criteria**: when Credential Manager is installed properly\ngit will ask for access credentials only once per each remote repos\nstorage (e.g. GitHub), normally on first attempt to push your local\nrepo to the remote.\n\nIf under **Windows** you are getting prompted for credentials repeatedly\nor presented with an error message\n```\nfatal: HttpRequestException encountered.\n   An error occurred while sending the request.\nfatal: HttpRequestException encountered.\n   An error occurred while sending the request.\nUsername for 'https://github.com':\n```\ntry the following command: `git config --global credential.modalPrompt true`.\nCheck official [docs](https://github.com/microsoft/Git-Credential-Manager-for-Windows)\nfor the fixes for other possible issues you may face. Keep this project\namong your bookmarks just for the case you face the authentication issue\nat some later time.\n\n## Friendly git editor\n\nMany won't find `vim` or `vi` (that are used by default by git)\nfriendly enough.\n\nAlternatives are:\n- [GNU emacs](https://www.gnu.org/software/emacs/download.html)\n- [Sublime Text](https://www.sublimetext.com/3)\n- [Visual Studio Code](https://code.visualstudio.com/download)\n- [Notepad++](https://notepad-plus-plus.org/download/) (Windows only)\n- `nano` (Linux/MacOS only)\n\n**NB**: Windows `Notepad.exe` is not a recommended option as\nit doesn't support Linux linefeed.\n\n**Windows**: if you're opted for `Notepad++` or `Nano` when\nwhen installed git and you're happy with your choice,\nyou may skip this section completely.\n\nYou may opt for a different editor of your choice. There is a couple of basic\nrequirements it should meet:\n- support Linux style linefeed\n- CLI friendly (normally offers an option like `--wait` to correctly handle files)\n- be lightweight enough to start quickly\n\nGoogle for \"your-editor-name as a git editor\" to check how to use your\nfavourite editor with git.\n\nInstall an editor of your choice (`git-editor-linux.sh` contains\ninstructions to install `nano` or `emacs`).\n\n**Emacs under Windows**: unpack\n[distribution archive](http://ftp.gnu.org/gnu/emacs/windows/emacs-26/emacs-26.1-x86_64.zip)\ninto `C:/Program Files/emacs`\n\n**MacOS**: You may need to move downloaded installations to Applications.\n\nSome editors come pre-bundled with OS, so try launching the editor of\nyour choice from Terminal to know if you need installing it first.\n\nOpen corresponding `git-editor-\u003cplatform\u003e.sh` to edit.\n`\u003cplatform\u003e` is your OS: `linux`, `macos`, or `windows`.\n\nUncomment (remove leading `# `) section that corresponds to your editor of choice and edit\nthe path to the editor executable as the pre-defined may not match actual\ninstallation path.\n\nLinux CLI commands `command -v \u003cexecutable_name\u003e` and `which \u003cexecutable_name\u003e`\nmay help you find proper path.\n\nThen launch the script with `./git-editor-\u003cplatform\u003e.sh`.\n\nIf the editor of your choice opens and you see something like\n```\n[user]\n\tname = John Doe\n\temail = john.doe@example.com\n\tusername = JohnDoe\n[core]\n\teditor = 'D:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin ''\n\tpager = cat\n[credential]\n\thelper = wincred\n```\nthen you have succeeded. Just close the editor.\n\n### What might go wrong?\n\n**You can see the file above but the editor is not the one you expected.**\n\nYou might not have all lines relevant to your editor in\n`./git-editor-\u003cplatform\u003e.sh` uncommented. So, the default editor didn't change.\n\n1. Quit the editor.\n   - If editor shows commands in a toolbar then press a relevant hot-key\n     (normally `^X` or `^Q`)\n   - If editor offers GUI then option to quit is located under File menu\n   - You may find yourself in `vim` or `vi`. Press `ESC`, type `:q!` and\n     hit `Return` key\n2. Uncomment relevant commands in `./git-editor-\u003cplatform\u003e.sh`\n   by removing leading `# `.\n3. Launch `./git-editor-\u003cplatform\u003e.sh`\n\n**Editor didn't start. Some error reported**\n\nThe path to the editor in `./git-editor-\u003cplatform\u003e.sh` is not correct.\n\n1. Fix path to your editor in `./git-editor-\u003cplatform\u003e.sh`.\n   Try finding proper path to your editor. Optionally consult google\n   for a proper path to the editor of your choice as described in\n   this section above.\n2. Launch `./git-editor-\u003cplatform\u003e.sh`\n\n**If you do not succeed either** then try setting different editor.\nDo not forget to comment back failing commands in `./git-editor-\u003cplatform\u003e.sh`\nbefore uncommenting commands for a different editor. Or yell for help\nin your student community.\n\n## Git Helpers\n\n### CLI Enhancements\n\nMake your terminal shell prompt informative.\nExecuting `./cli-tune.sh` will copy `.bash_profile`,\n`git-completion.bash` and `git-prompt.sh` to your $HOME.\n\nThe above improves CLI by e.g. adding info about current git branch\nto the shell prompt and adding auto-completion feature to git commands\n(branch names, commands per se, etc.).\n\nIt may happen that either of file copying operation fails. Most likely\neither of files already exists at target directory (`~/`). There are\nchances you have already tuned your CLI for git any time before.\nAs for the `.bash_profile` you may already have one, then just\nupdate `~/.bash_profile` with contents of this project's `.bash_profile`.\n\nYou'll need to close and re-open Git Bash before any changes take effect.\n\nCredits:\n[Udacity](https://classroom.udacity.com/courses/ud775/lessons/2980038599/concepts/33417185870923)\n\nLearn more about\n[Customizing Linux/Mac terminal prompt](https://gist.github.com/ankurk91/2efe14650d54d7d09528cea3ed432f6d)\n\n### Git Aliases\n\nExecuting `./git-helpers.sh` will:\n * add global `.gitignore` to ignore most common file patterns\n * add a collection of aliases/shorthands\n\n * Study `git-helper.sh`, try commands assigned to aliases\n   on some of your repos to see what those do.\n   Some of aliases:\n\n**More on global `.gitignore`**:\nGlobal `.gitignore` decreases a risk of tracking of the most\ncommon files to be ignored (IDE settings, temporary files,\ndirectories for app builds etc). Global `.gitignore` works\neven when the project doesn't contain its own `.gitignore`.\nYou may add more rules or remove some by editing `~/.gitignore`.\n\n**More on aliases**:\nAdding those is not harmful, using can be.\nStudy `git-helper.sh`, try commands assigned to aliases\non some of your repos to see what those do.\n\n### Git Flow\n\n#### Basic flow\n\nExecuting `./git-flow-basic.sh` will add aliases to support some\nbasic git flow.\n\n* `sync-main-upstream` - updates local `main` and `origin/main`\n  with `upstream/main`\n* `sync-branch-upstream-merge-main`\n    - calls `sync-main-upstream`\n    - updates feature branch from `main` using simple merge strategy\n* `sync-main` - updates local `main` from `origin/main`\n  when on a feature branch\n* `sync-branch-rebase-main` - rebases current branch onto\n  `main`; conflicts may arise\n* `sync-branch-continue` - completes rebasing after conflict resolution\n\nUse the following aliases if repo's main branch is named `master`.\n * `sync-master-upstream` - updates local `master` and `origin/master`\n   with `upstream/master`\n * `sync-branch-upstream-merge-master`\n   - calls `sync-master-upstream`\n   - updates feature branch from `master` using simple merge strategy\n * `sync-master` - updates local `master` from `origin/master`\n   when on a feature branch\n * `sync-branch-rebase-master` - rebases current branch onto (updated)\n   `master`; conflicts may arise\n * `sync-branch-continue` - completes rebasing after conflict resolution\n\nAdd and use those when you clearly understand what is behind. This\nis also a rather source of inspiration to build your own git flow\nthan a commonly recognized pattern.\n\n#### Git Town\n\nGit town is yet another opinionated git flow toolset.\n\nLearn and use [git-town](http://www.git-town.com/install.html)\nwhen you feel it matches the git flow you'd use.\n\nExecuting `./git-town-set.sh` offers some initial settings, and\nworks when git town is installed.\n\n## More resources on tweaking git\n\n * [First-Time Git Setup](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup)\n * [yevhenorlov/dotfiles@github](https://github.com/yevhenorlov/dotfiles)\n * [Git going with aliases](https://hackernoon.com/git-going-with-aliases-a9706e23fa9c)\n * [https://medium.com/@vitalyb/creating-powerful-git-aliases-3dfc0efc9a31](https://medium.com/@vitalyb/creating-powerful-git-aliases-3dfc0efc9a31)\n * [robmiller/.gitconfig@github](https://gist.github.com/robmiller/6018582)\n\n## Advanced\n\n### Subrepo\n\n[git-subrepo](https://github.com/ingydotnet/git-subrepo) is a great replacement\nfor `git-submodule` and `git-subtree`.\nPlease, refer to:\n * [project docs](https://github.com/ingydotnet/git-subrepo/wiki)\n   for more details\n * [Repo import and export back](https://gist.github.com/OleksiyRudenko/86d378b56fe690e47a066b8eeb4ac5b2)\n   article for a use case\n * an [article in Russian](https://habr.com/ru/post/428493/) for a general overview\n   (a bit outdated)\n\n## IDE minimal tweak\n\nTune your editor/IDE so it ensures empty line at the end of file.\n\nFind and check the relevant setting. Examples:\n  - IntelliJ IDEA products: File \u0026gt; Settings (or _ProductName_ \u0026gt; Preferences)\n    \u0026gt; Editor \u0026gt; General -- Ensure line feed at file end on Save\n  - [VS Code](https://stackoverflow.com/questions/44704968/visual-studio-code-insert-new-line-at-the-end-of-files)\n  - Sublime: Command Palette \u0026gt; Preferences -- change or add `\"ensure_newline_at_eof_on_save\": true`\n\n\u003e This ensures that adding code/text at the end of file will not mark\nthe fragment that actually had not been effectively changed\n(which takes place when a line doesn't end with LF character).\nThis makes history of changes cleaner and diffs reflecting actual changes.\n\n### `.editorconfig`\n\nSome editors and IDEs support [`.editorconfig`](https://editorconfig.org/)\nout-of-the-box, others may require plugins.\nCheck how your editor/IDE is [supported](https://editorconfig.org/#download).\n\nCopy `.editorconfig` with basic settings from this project to the root\ndirectory of your own projects.\n\nIf your own projects are located somewhere under your home\ndirectory (the default case) `cp ./.editorconfig ~/` will do.\n\nYour editor/IDE may require to enable `.editorconfig` somewhere in its settings.\n\n## Issues?\n\nIf anything above contains errors, not quite clear or requires\nimprovement or update, please, feel free adding an\n[Issue](https://github.com/OleksiyRudenko/dev-env-git/issues).\n\n## Contributors\n\nThere are people that contributed to this project by testing instructions\nherein and providing their feedback. Support and willingness to help\nis much appreciated.\n\n- [sayckl](https://github.com/sayckl)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleksiyrudenko%2Fdev-env-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleksiyrudenko%2Fdev-env-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleksiyrudenko%2Fdev-env-git/lists"}