git push

# 将本地分支的更新,推送到远程主机
git push <远程主机名> <本地分支名>:<远程分支名>

# 将本地的master分支推送到origin主机的master分支。如果master不存在,则会被新建。
git push origin master

# 如果省略本地分支名,则表示删除指定的远程分支,因为这等同于推送一个空的本地分支到远程分支
git push origin :master
# 等同于
git push origin --delete master

# 将所有本地分支都推送到origin主机
git push --all origin

# git push不会推送标签(tag),除非使用–tags选项
git push origin --tags

# 推送tag
git push origin tag_name

# 删除远程标签
git push origin :tag_name

查看log

# 查看某个用户的提交记录:
git log --author=<user_name>
# 查看某文件的提交历史:
git log -p <file_path>

重命名本地分支

# 重命名指定分支:
git branch -m <oldname> <newname>
# 重命名当前分支:
git branch -m <newname>

删除远程分支

# 删除远程分支:
git  push origin --delete <br_name>

查看git配置

git config -l

git 配置

系统级配置

对应的配置文件为<git_setup_dir>/etc/gitconfig

git config --system user.name "username"
git config --system user.email "username@xx.com"

全局级配置

对应的配置文件为~/.gitconfig

git config --global user.name "username"
git config --global user.email "username@xx.com"

仓库级配置

对应的配置文件为.git/config

git config --local user.name "username"
git config --local user.email "username@xx.com"

设置gui的编码

默认情况下,使用gitk查看代码时,代码中的中文会乱码,设置gui编码为utf-8后问题解决。

git config --global gui.encoding utf-8

生成ssh公钥文件

# 生成
ssh-keygen -t rsa -C "your_email"
# 查看
cat ~/.ssh/id_rsa.pub

常用git配置

[user]
    email = xxx
    name = xxx
[alias]
    st = status
    br = branch
[color]
    ui = auto

参考:
http://www.cnblogs.com/lovezbs/p/4455784.html
http://blog.csdn.net/u014132720/article/details/51471630
http://www.yiibai.com/git/git_push.html

标签: linux, git

添加新评论