Skip to content

Instantly share code, notes, and snippets.

@eagleon
Last active November 6, 2015 08:38
Show Gist options
  • Save eagleon/7172e17b6179f20f801d to your computer and use it in GitHub Desktop.
Save eagleon/7172e17b6179f20f801d to your computer and use it in GitHub Desktop.
Git常用技巧

#Git常用技巧

##1. windows下使用git,如何保存push到远程仓库时使用的密码: push到远程仓库时,不同系统下面如何去保存验证信息。其中提到了一个软件:git-credential-winstore
把git-credential-winstore放到git\bin下,然后执行:

  git config --global credential.helper winstore 

git 2.0后

git config --global credential.helper store

##2. git 同时推送到多个分支 方法一:

git remote add origin <url> # 主要的URL
git remote set-url --add origin <url>  #次URL。

这样的话,git push origin master 就会把master提交到两个分支,但是git pull 只能拉取origin里的一个url地址,这个fetch-url默认为 你添加的到origin的第一个地址。

如果你想更改,只需要更改config文件里,那三个url的顺序即可,fetch-url会直接对应排行第一的那个utl连接。

方法二:

$ git config alias.pushall "!git push origin && git push dev"

##3. git添加快捷命令 C:\Program Files (x86)\Git\etc\gitconfig

[alias]
    co = checkout
    br = branch
    ct = commit
    st = status
    last = log --pretty=oneline -1 HEAD
    lg = log --graph  --abbrev-commit --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%Cblue%an%Creset%Cgreen %cr)%Creset '

[merge]
	ff = false

##参考资料 http://blog.csdn.net/isea533/article/details/41382699 Git提交到多个远程仓库 http://my.oschina.net/shede333/blog/299032 git 给远程库 添加多个url地址

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment