Git Learner Record
2015-10-01 21:07
281 查看
目录
目录What is a git
Preparation
History
Install
configuration
Begin
init the git
stream
File Operations
Add git status to check
Removegit status to check
Renamegit status to check
Rollback
git diff to check to change
Warning git reset
gitignore
gitkeep
Other options
Branch
branch is needed cheap try
operations
Merge
stash
Remote link to the github or others
Set up a github account
password caching
What is a git
git 帮助我们进行代码的版本控制,我于2015/10/1花费一天时间学习一个关于git的视频,然后再参考几篇博客,将git的使用方法全部弄清楚。let's begin!
Preparation
History
SCCS Source Code Control System1972, closed source, free with Unix
RCS Revision Control System
1982, open source.
CVS Concurrent Versions System
1986 - 1990, open source
SVN
2000, open source
BitKeeper SCM
distributed version
GIT
github come out
Install
参考官网的安装方法 —— [git web]download the tar.gz or some package[your linux]
tar zxvf *.tar.gz
/configure
make && make install
finish.
or you can try:
apt-get install git
yum install -y git
pacman -S git
configuration
git config –global user.name [your name]git config –global user.email [your email]
git config –global core.editor “vim”
git config –global color.ui true
use bash config
wget https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
ls
mv git-completion.bash ~/.git-completion.bash
add to .bashrc that if exist this bash, source it.
help
Begin
init the git
mkdir dir1cd dir1
git init
add one file (make change)
git add . (add change)
git commit -m “some word” (commit change)
git log -n/ –since/ –until/ –grep
stream
working -add file- staging index -commit- repositiryFile Operations
Add (git status to check)
git add .git commit -m “”
git diff
git commit -ma “”
Remove(git status to check)
git rm filenamegit commit -m “”
Rename(git status to check)
git add filegit rm file
git commit -m “”
or you can use git mv file1 file2
Rollback
git diff to check to change
git checkout – file(before add)it can return the status of the workspace.
git reset HEAD file (after add)
unstage the file -> before add
git checkout – file
git (after commit)
find the Hash value of commit
git comment –amend append to the same commit
git diff –staged
return the commit status
git checkout [commit hash] – file
Warning [git reset]
–soft not change staging index & workspace–mixed(default) change staging & not workspace
–hard change staging & change workspace
usage : git reset –soft [commit hash]
git reset HEAD file
-n try to do -f force to do
.gitignore
it can help us to ignore some file or dirreference :
1. help.github.com/articles/ignoring-files
2. github.com/github/gitignore
git config –global core.excludesfile pathtofile
* git rm –cached file
.gitkeep
git log –oneline/ –graph/ –all/ –decorateOther options
git show [hash]git diff [hash] & git diff [hash1]..[hash2]
Branch
branch is needed, cheap, try
try new ideasisolate the workspace
fast context switching
operations
git branchcreate -> git branch new_branch_name
switch -> git checkout branch_name
git checkout -b new_branch_name
git diff [branch1]..[branch2] (use –color-words)
git branch –merged
git branch -m old_name new_name (–move)
git barnch -d(–delete) name (-D to delete a non-empty branch)
prompt
export PS1=’$(__git_ps1 “(%s)”) > ‘
export PS1=’\W$(__git_ps1 “(%s)”) > ‘
export PS1=$PS1’$(__git_ps1 “(%s)”) > ’ (it’s cool !)
Attantion: barnch is a stack mode, current branch can’t be delete
Merge
git merge exist_branchgit branch –merged
conflict
change by yourselt
git log –graph –oneline –all –decorate
git mergetool –tool=
Attention:
* keep lines short
* commits small focused
* merge often
stash
git stash save “changed mission …”git stash list
git stash show stash@{0} (you may use -p option)
git stash apply
git stash pop
git stash drop stash@{0}
Remote (link to the github or others)
Easily, this can be changed to
Set up a github account
you set up a accountCreate a repository
look at the code following
echo # >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/[User account]/[project name].git git push -u origin master
you can easy use
git remote rm origin
git branch -a/-r
git push -f
git fetch
fetch before work
fetch before push
fetch often
git pull = git fetch + git merge
git push origin :your branch
git push origin [–delete] branch
[远程
4000
分支的使用]
git checkout -b [new_branch]
(make some change)
git commit -am “word”
git push [远程仓库名] [远程分支名(new_branch)]
password caching
Password Cachingor save the ssh key.
相关文章推荐
- PowerDesigner 15.1 安装步骤详细图解及破解
- php、nignx虚拟主机配置
- JDK配置
- 随机森林
- Android stutio使用故障
- HDU 4850 欧拉回路的思想
- C++容器(二):关联容器简介
- 【文件读写】PHP知识点总结-02
- C++容器(二):关联容器简介
- php、nignx虚拟主机配置
- Hetman Uneraser 3.6.1 中文多语免费版 恢复已删除文件和文件夹工具
- 关于树:直径,重心
- URAL 1557 连通性
- 剑指offer - 从上往下遍历二叉树
- 通过CIFilter快速生成二维码
- codeforces 559D Randomizer
- 本地mapReduce项目报错:java.lang.NullPointerException at java.lang.ProcessBuilder.start...
- jsp实现新闻内容或超长文章的分页
- [STL]priority_queue
- nyoj 一种排序 8 (结构体 排序)