git 常见用法

 

git命令太长,alias来帮忙。

git命令太长,可以使用alias来给对应的命令取个别名。在/etc/profile中添加以下内容:

alias gst='git status'
alias gpu='git push'
alias gff='git diff'
alias gpl='git pull'
alias gchk='git checkout'

git add --all && git commit -am"{comment}" && git push 可以通过一个简单的脚本来替代,脚本内容如下:

#!/bin/bash

cd `pwd`
comment=$@
if [ $# == 0 ]; then
	echo "USAGE: gitpush COMMENT" 
	exit 1
fi
git add --all && git commit -am"${comment}" && git push

把上述脚本保存成gps.sh, 并把该脚本保存位置添加到PATH环境变量中。提交代码的命令就大大地简化了,只需要执行gps 注释命令,文件改动将会提交到远程仓库。

使用git时,遇到的问题及解决办法

  • Git Unlink of file ‘.git/objects/pack/pack-***.pack’ failed.

    just run the command as below can solve it

      git gc
      git repack -d -l
    

see more. Pro Git