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

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

四、IDEA中的图形化git操作

4.1 git commit

在菜单栏找到git > commit
idea-git-commit-1.png
点击进入窗口
idea-git-commit-2.jpg
确认无误,点击commit后,IDEA还会帮你check一下更改文件的代码语法与警告。
idea-git-commit-3.jpg

学术论文 LaTeX 与 Word 排版 Operating System Maintainance and Cleaning

评论

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

×