git 操作中的一些小技巧

整理记录平时遇到的一些git技巧

1. branch for fixing issue

1
2
3
4
5
6
7
8
9
10
11
12
git checkout -b fix-bug
// git add 一些修改文件
git commit -m "fix 1"
// git add 再一些修改文件
git commit -m "fix 2"
git checkout master
git pull -r origin master
git checkout fix-bug
git rebase master
git checkout master
git merge --squash fix-bug
git commit -m "fix bug"

2. Pull a remote branch

Ensure in advance that you ref all branches in .git/config, then

1
2
git fetch --all
git checkout -b branchname origin/branchname

A successful example:
fetch-remote-branch

TroubleShooting: Cannot git pull from github

1
2
3
4
5
6
kex_exchange_identification: read: Connection reset by peer
Connection reset by 20.205.243.166 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Try ssh -T git@github.com and then git pull.

3. prevent typing password in http protocol

3.1 Git Credential store

1
git config --global credential.helper store

After enabling this you will be prompted for your creds on your next commit. your token will be stored in plain text in ~/.git-credentials.

3.2 Microsoft Git Credential Manager

Step 1: aur install git-credential-manager-core-bin developed by Microsoft then config:

1
git-credential-manager-core configure

Step 2: For Linux system, a default strategy for storing credential passwords doesn’t exist. So one of the four options of storing credentials should be configured by setting the GCM_CREDENTIAL_STORE environment variable or credential.credentialStore git configuration setting.
environment variable way:

1
export GCM_CREDENTIAL_STORE=secretservice # secretservice / gpg / cache / plaintext

Or

1
git config --global credential.credentialStore secretservice #  secretservice / gpg / cache / plaintext
On Typesetting a Thesis by Using Either LaTeX or Word Operating System Maintainance and Cleaning

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×