Showing posts with label GIT. Show all posts
Showing posts with label GIT. Show all posts

7/19/2017

Make gitg settings better

Change the font of the source view part:
gsettings set org.gnome.desktop.interface monospace-font-name "Ubuntu Mono 11"

7/16/2017

How to setup cygwin

Install Cygwin: https://cygwin.com/install.html
If you need to install new packages, run the installer again!

Packages to install:
python
openssh
emacs

Because the version with cygwin package has slowness problem, to use git:
Install https://gitforwindows.org/
Add:
/cygdrive/c/Program Files/Git/mingw64/bin to PATH environment variable.
Need to change some git colors in cygwin:
git config --global color.diff.meta black
To use gitk:
Make sure gitk runs: /cygdrive/c/Program Files/Git/cmd/gitk (May need to restart the computer or something, not sure why it didn't work for the first try and all of a sudden, it worked)

Change git core.editor to "D://Programs//wscite//scite.exe"
Install meld, then run:
git config --global merge.tool meld
git config --global diff.tool meld

git config --global mergetool.meld.path "C://Program Files (x86)//Meld//Meld.exe"
git config --global --add difftool.prompt false
git config core.symlinks false

In .bash_profile, add
. ~/.bashrc

Download https://onedrive.live.com cygwin_home folder.

Set HOME environment variable set to C:\Users\liangzou (Must be done first. Need to logout and login again)
To make ssh use the .ssh/config in the home directory:
rm -rf /cygdrive/c/cygwin64/home/liangzou
cd /cygdrive/c/cygwin64/home/
ln -s /cygdrive/c/Users/lltou liangzou

    
     Optional:
  1. Verify your Cygwin /etc/passwd does not exist
  2. "mkpasswd -l > /etc/passwd" (this will insert many accounts into your new /etc/passwd)
  3. Change the user name in the /etc/passwd to the one you want.
  4. kill all cygwin shells
  5. bring up a new cygwin shell

If ctrl+arrow appears as ;5C or ;5D, make sure ~ is pointing to C:\Users\liangzou instead of /home/liangzou, which should be pointing to C:\Users\liangzou

Install Windows Terminal, then use the config settings:

===============
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions": 
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        // { "command": "paste", "keys": "ctrl+v" },
        // Press Ctrl+Shift+F to open the search box
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 0
            },
            "keys": "alt+1"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 1
            },
            "keys": "alt+2"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 2
            },
            "keys": "alt+3"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 3
            },
            "keys": "alt+4"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 4
            },
            "keys": "alt+5"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 5
            },
            "keys": "alt+6"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 6
            },
            "keys": "alt+7"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 7
            },
            "keys": "alt+8"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 8
            },
            "keys": "alt+9"
        },
        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{f1c07b24-77de-4f9a-9a53-e9b7788c150e}",
    "disableAnimations": true,
    "largePasteWarning": false,
    "multiLinePasteWarning": false,
    "profiles": 
    {
        "defaults": 
        {
            "antialiasingMode": "cleartype",
            "colorScheme": "liang",
            "cursorColor": "#FF0000",
            "cursorShape": "filledBox",
            "fontFace": "Ubuntu Mono - Bront",
            "fontSize": 11
        },
        "list": 
        [
            {
                "closeOnExit": "graceful",
                "commandline": "C:/cygwin64/bin/bash.exe --login -i",
                "guid": "{f1c07b24-77de-4f9a-9a53-e9b7788c150e}",
                "historySize": 999999,
                "icon": "C:/cygwin64/Cygwin-Terminal.ico",
                "name": "Cygwin",
                "padding": "0, 0, 0, 0",
                "snapOnInput": true,
                "useAcrylic": false
            },
            {
                "commandline": "cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "commandline": "powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": true,
                "name": "Windows PowerShell"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": true,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        },
        {
            "background": "#F5E7D1",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#000000",
            "green": "#13A10E",
            "name": "liang",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#000000",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        }
    ],
    "showTabsInTitlebar": false,
    "theme": "light",
    "wordDelimiters": " ()$\"';:<>[]\u2502"
}

=======================


7/06/2017

GIT command autocomplete with alias/aliases

# To Setup:
# 1) Save the .git-completion.bash file found here:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# 2) Add the following lines to your .bash_profile, be sure to reload (for example: source ~/.bash_profile) for the changes to take effect:
# Git branch bash completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
__git_complete g __git_main
__git_complete gc _git_checkout
__git_complete gm __git_merge
__git_complete gp _git_pull
fi
# Make sure you actually have those aliases defined, of course.
alias g="git"
alias gc="git checkout"
alias gm="git merge"
alias gp="git pull"

8/29/2016

GIT commonly used commands

# How to remove unwanted file from last commit
git reset --soft HEAD~1
Then reset the unwanted files in order to leave them out from the commit:
git reset HEAD path/to/unwanted_file
Now commit again, you can even re-use the same commit message:

git commit -c ORIG_HEAD

# How to resolve conflicts
After git rebase "branch", there may be conflicts.
If you want to accept the changes from the "branch" , just run:
git checkout --ours
Or If you want to accept the changes from current branch, just run:
git checkout --theirs

Or
git rebase -s ours

How to fix this error: error: The following untracked working tree files would be overwritten by merge:
git fetch --all
git reset --hard origin/master

# Change the remote

git remote rm origin
git remote add 'the url'
git pull origin main
 
# Set the origin/main as the up stream
git branch -u origin/main main
 
# Push the branch wip to the remote origin
git push origin wip

# Ignore a local folder without checking in the .gitignore file
echo yougood-base >> .git/info/exclude
git update-index --assume-unchanged yougood-base

Submodules
=========

g submodule add https://github.com/google/protobuf.git third_party/protobuf
g submodule update --init  # to clone all submodules


How to re-init submodules
emacs .git/config: delete all submodule related items
Then run: git submodule init


After git pull in the main repo, need to run the following commands:
git submodule sync --recursive
git submodule update --recursive


git diff shows no changes, but git status shows a list of modified files:
Open .git/config and make sure:
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        ignorecase = true
        autocrlf = false
        symlinks = false


======
To setup github ssh access
For error: ex_exchange_identification: Connection closed by remote host
 
I guess GFW make it.
By checking: https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
which I followed the ~/.ssh/config added the port 443.
and use command like: "proxychains -q git pull", it is working now.

Here is what is working now through https, and through proxy:

❯ proxychains -q ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
Hi LeisureLinux! You've successfully authenticated, but GitHub does not provide shell access.


8/05/2016

Make git settings better

Copy to ~/.gitconfig
====================
[difftool]
    prompt = false
[gitreview]
    remote = origin
[gui]
    fontui = -family Consolas -size 15 -weight normal -slant roman -underline 0 -overstrike 0
    fontdiff = -family Consolas -size 15 -weight normal -slant roman -underline 0 -overstrike 0
[core]
    editor = emacs -nw
    # Remove the windows trailing space diffs
    autocrlf = input
[diff]
    tool = meld
[merge]

    tool = meld