Sep. 3, 2020
I need to do dev of work on my personal laptop. Usually, I will clone the repository and set a work email for that repository by git config user.email <your@email.com>. That requests config for each working repositories, and if there are other settings, it requires more actions. And most important, I forget to set up it sometimes.
Later, I did search on the internet and found I am actually able to set a separated gitconfig for the specific folder. Below are the steps.
Create a separated gitconfig file ~/.gitconfig-work
Add the settings you need into the file, like email/name git config -f ~/.gitconfig-work user.email <your@email.com>
Now we have gitconfig file for working.
Include the config file to gitconfig git config --global include.path "~/.gitconfig-work"
Set work folder to use the new config file git config --global "includeIf.gitdir:~/work/.path" "~/.gitconfig-work"
Then for all repositories inside of work folder, it will use the new config file.
Bouns Add isWork to the new config file
git config -f ~/.gitconfig-work core.isWork true
And run below command inside of the work folder to see if the config is applied
git config --get core.isWork || echo false
credit/reference: [https://filipe.kiss.ink/multiple-gpg-keys-git/]
Jan. 15, 2019
Install gnupg and pinentry-mac brew install gnupg brew install pinentry-mac Generating a GPG key Generating key gpg --full-generate-key
Checking my key gpg --list-secret-keys --keyid-format LONG
Copying key gpg --armor --export 3AA5C34371567BD2 | pbcopy
Setting key for git git config --global user.signingkey 3AA5C34371567BD2
Full help https://help.github.com/articles/generating-a-new-gpg-key/
Setting to load key nvim .gnupg/gpg-agent.conf
pinentry-program /usr/local/bin/pinentry-mac
Backup and restore gpg --export-secret-keys KEY_ID > my-private-key.asc gpg --import my-private-key.asc
Apr. 16, 2014
I think it’s more effective to use git cli than gui whatever which system you are using.
For example, you need switch branch, it’s just one line in cli
git checkout [branch] But (eg. windows) you need right click -> choose command -> click -> choose branch -> click
It’s ok if you just do this few times. However, if you like me, going to 10+ repositories and switch to different branches everyday. Command line is your best friend to help you save your time.
Terminal under Mac or *nix is native and easy to use. However, if you are using windows, after you install git, there is git bash to let you easy use git.
Then there is a problem, each time you push, pull, or commit, it requests you to type your ssh password.
What I did is every time when open a new terminal window, it will ask you your ssh password once, then whatever you do, it won’t ask you password again until you close this seesion window.
Please find this file, if you could not find it, then create one.
$HOME\\.bashrc In this file, add below’s code
eval `ssh-agent` ssh-add Now every time, when you open a new git bash window, it will your password once, and you can run as many commands as you want without popup to ask your password again.
Oct. 11, 2013
for REPO in `ls`; do (cd "$REPO";git pull); done; update
find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} fetch \; https://github.com/imjma/dotfiles/blob/master/zsh/alias.zsh#L54
Jun. 22, 2012
We are using git-flow as git branching model to do development.
However, there are more and more feautre branches were generated, and we need to make a list quickly for all branches to see which branch is still under development and not merged into master branch sometimes.
Then this command will give a huge help.
git branch --no-merged master
And if add -a you can get all include remote branches.