Tag: git

  • git-bash to windows terminal

    git-bash to windows terminal

    The article is about adding git-bash prompt to Windows Terminal, windows Terminal is a separate utility and should not be confused with the windows command prompt or windows power shell.

    The Windows Terminal is a modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and custom themes, styles, and configurations.

    You can get Windows Terminal from Microsoft store.

    Git Bash is a source control management system for Windows. It allows users to type Git commands that make source code management easier through versioning and commit history. Bash is a Linux-based command line (that has been ported over to Windows) while Shell is a native Windows command line.

    By Default Windows Terminal doesn’t come with git-bash added to it, one can add git-bash on the windows terminal following the below steps

    1. Open settings with Ctrl+,
    2. To make git-bash available you’ll need to append to the profiles options below to the "list": portion of the settings.json file:
    Open settings.json in Windows Terminal sidebar
    {
        "$schema": "https://aka.ms/terminal-profiles-schema",
    
        "defaultProfile": "{00000000-0000-0000-ba54-000000000001}",
    
        "profiles":
        {
            "defaults":
            {
                // Put settings here that you want to apply to all profiles
            },
            "list":
            [
                <put one of the configuration below right here>
            ]
        }
    }
    

    Profile options

    Uncomment correct paths for commandline and icon if you are using:

    • Git for Windows in %PROGRAMFILES%
    • Git for Windows in %USERPROFILE%
    • If you’re using scoop
    {
        "guid": "{00000000-0000-0000-ba54-000000000002}",
        "commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
        // "commandline": "%USERPROFILE%/AppData/Local/Programs/Git/bin/bash.exe -l -i",
        // "commandline": "%USERPROFILE%/scoop/apps/git/current/usr/bin/bash.exe -l -i",
        "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
        // "icon": "%USERPROFILE%/AppData/Local/Programs/Git/mingw64/share/git/git-for-windows.ico",
        // "icon": "%USERPROFILE%/apps/git/current/usr/share/git/git-for-windows.ico",
        "name" : "Bash",
        "startingDirectory" : "%USERPROFILE%"
    }

    You can also add other options like:

    {
        "guid": "{00000000-0000-0000-ba54-000000000002}",
        // ...
        "acrylicOpacity" : 0.75,
        "closeOnExit" : true,
        "colorScheme" : "Campbell",
        "cursorColor" : "#FFFFFF",
        "cursorShape" : "bar",
        "fontFace" : "Consolas",
        "fontSize" : 10,
        "historySize" : 9001,
        "padding" : "0, 0, 0, 0",
        "snapOnInput" : true,
        "useAcrylic" : true
    }

    For sample here is my configuration, i have git-bash in my AppData profile, so the path is a little different

            {
                "guid": "{88139bd0-320b-4050-8215-ac23efa13cad}",
                "commandline": "C:\\Users\\<username>\\AppData\\Local\\Programs\\Git\\bin\\bash.exe -i -l",
                "icon": "D:\\Users\\<username>\\AppData\\Local\\Programs\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "name" : "Bash",
                "startingDirectory" : "%USERPROFILE%"
            }

    Once your setup is complete, you should be able to see something like this in your windows terminal

    Notes

    • make your own guid as of https://github.com/microsoft/terminal/pull/2475 this is no longer generated.
    • the guid can be used in in the globals > defaultProfile so you can press you can press CtrlShiftT or start a Windows terminal and it will start up bash by default
    "defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
    
    • -l -i to make sure that .bash_profile gets loaded
    • use environment variables so they can map to different systems correctly.
    • target git/bin/bash.exe to avoid spawning off additional processes which saves about 10MB per process according to Process Explorer compared to using bin/bash or git-bash
    • icon field to: "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico"
    • icon can also be referenced like this: "icon" : "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico"

    The article is taken from StackOverflow answer written by Archimedes Trajano.

  • Git Simplified.

    Set up with github. (Very good tutorial from Lifehacker)
    How the Heck do i use Github

    To remove the origin
    git remote remove origin

    To add origin
    git remote add origin https://github.com/<username>/<repository name>.git

    — Please do not add the “< >” while using the above command.
    for e.g. https://github.com/omps/webdevel.git

    use the origin as SSH and without authentication.
    you can follow the stack overflow question on this. 
    or can just add 
    “git remote add origin ssh://git@github.com/<username>/<repository name>.git

    To push to the repository.
    git push origin master
    If you have created the directly locally and wanted to push it to the github.com server, you may need to force the origin master.
    i did as “git push origin master –force”, please note that this may wipe your existing content.

    How to deploy keys.
    Github article.

    Generating keys
    A very good github tutorial related to generating keys for github.

    When the permission is denied.
    github’s own manual to fix it.

    More to come…….