gitNote - juedaiyuer/researchNote GitHub Wiki
#首次使用git,需要设定本地库的用户邮箱和用户名
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git rm 删除
git add . 一次性添加未提交的文件
远程主机的版本库有了更新(git术语为commit),需要将这些更新取回本地
git fetch <远程主机名> <分支名> 获取远程库最新信息
git diff 本地库 远程库 查看改动
git pull 直接拉取远程库并且合并;实际上git fetch,git merge更安全些,可以在git fetch之后,查看更改情况.
git branch -r 远程主机名/分支名
git branch -a 查看所有分支
git checkout -b newBranch 远程主机名/分支名 在分支的基础上创建一个新的分支
git merge 远程主机名/分支名 在本地分支上合并远程分支
git rebase 远程主机名/分支名
git pull 本质是将远程库拉到了本地库(不包括工作区,暂存区...)
git remote -v show what urls you have set
git remote set-url origin https://github.com/YOUR-USERNAME/your-repo.git set your url
#一般在用https的时候,每一次push,都需要输入用户名和密码,所有用到了cache技巧来避免;
#个人习惯设置1天的时间,单位秒
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=86400'
git config --local -e
--local 查看仓库级的config
创建分支和切换分支
git branch name 创建新分支
git checkout name 切换到新分支
git checkout -b name 前两个命令的总和
git brach 不带参数:列出本地已经存在的分支,并且在当前分支的前面加“*”号标记
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
- 以斜杠“/”开头表示目录;
- 以星号“*”通配多个字符;
- 以问号“?”通配单个字符
- 以方括号“[]”包含单个字符的匹配列表;
- 以叹号“!”表示不忽略(跟踪)匹配到的文件或目录;
fd1/* 忽略目录fd1下的全部内容,包括子目录
#忽略~结尾的文件
*~
雪峰大大博客上已经详细讲述...
方便每次的push操作
- SmartGit(跨平台)-using,需要付费
- SourceTree(跨平台)
- git gui---using
sudo apt-get install git-gui
Alt+F2,输入git gui来运行
付费软件
目前运行进入文件目录,运行bin下的sh文件,个人习惯
授权文件
Windows: %APPDATA%\syntevo\SmartGit\
OS X: ~/Library/Preferences/SmartGit/
Unix/Linux: ~/.smartgit/
and remove the file settings.xml
命令行下载
sudo add-apt-repository ppa:eugenesan/ppa
sudo apt-get update
sudo apt-get install smartgithg