❯ cat ~/.gitconfig [include] path = /etc/git-setup/gitconfig [core] editor = vi [user] name = email = [merge] tool = vimdiff [alias] co = checkout ci = commit st = status br = branch hist = log --graph --format=format:\"%C(red)%h%C(reset) %C(yellow)%cd%C(reset) | %s %C(green)\\[%an\\]%C(reset)%C(bold blue)%d%C(reset)\" --abbrev-commit --date=short root = rev-parse --show-toplevel alias = !git config --list | grep ^alias head = rev-list -n1 --abbrev-commit HEAD l = log --stat --color --graph --pretty=format:'%C(bold red)%h%C(reset) - %C(bold green)(%cr)%C(bold blue)<%an>%C(reset) -%C(bold yellow)%d%C(reset) %s' --abbrev-commit [init] defaultBranch = main
1.3 修改本地 branch name
1 2 3 4 5
git branch -m master main $ git branch -m old_branch new_branch # Rename branch locally $ git push origin :old_branch # Delete the old branch $ git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
/tmp/test master:main ⇡1 ❯ git branch -m master main
enwaiax@enwaiax-dev /tmp/test main ⇡ /tmp/test main ⇡1 ❯
2. commit 本地改动
1 2 3 4 5
$ git add . # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. $ git commit -m "First commit" # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.