git常用命令
Posted
在github下初建并提交
git init
git remote add origin git@github.com:xxxx/xxxx.git
git pull origin master
git branch cgg #本地分支
vi README
git add README
git commit -m "brinch cgg update master"
git pull origin master
pull某一个版本到当时分支
git pull origin dev_brisk_cgg
看远程分支
git branch -r
从本地cog提交远程master
git push origin cog:master
取消对文件的修改
$ git checkout -- benchmarks.rb
本地取消最后一个commit(代码不会还原)
git reset HEAD^
如果commit以后还想添加到本地中
$ git add xxx
$ git commit --amend
任何标识或其他修改。 或使用gitk浏览视觉的变化。
git show HEAD
占存切换分支
$ git add config/deploy.rb
$ git checkout cgg_stable
error: Your local changes to the following files would be overwritten by checkout:
config/deploy.rb
Please, commit your changes or stash them before you can switch branches.
error: Your local changes to the following files would be overwritten by checkout:
config/environments/development.rb
Please, commit your changes or stash them before you can switch branches.
Aborting
$ git stash
Saved working directory and index state WIP on master: 3465109 thin edit
HEAD is now at 3465109 thin edit
$ git checkout cgg_stable
Switched to branch 'cgg_stable'
$ git checkout master
Switched to branch 'master'
$ git stash list
stash@{0}: WIP on master: 3465109 thin edit
$ git stash apply stash@{0}
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: config/deploy.rb
# modified: config/environments/development.rb
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# public/profile/
# vendor/cache/
$ git stash clear
取消已经暂存的文件
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README.txt
# modified: benchmarks.rb
#
$ git reset HEAD benchmarks.rb
benchmarks.rb: locally modified
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README.txt
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: benchmarks.rb
#
文件某个文件的日志
git log -p filename
或
gitk filename
继续补充中。。。。
此文章 短链接: http://dlj.bz/SRsbfT
Tag Cloud
AFNetworking(1)
AngularJS(2)
Devise(1)
Devops(1)
Homebrew(1)
MacOSX(11)
Rails4(2)
TTS(1)
Unauthorized(1)
analysis(1)
android(1)
apache(2)
api(1)
assets(5)
backup(3)
blog(1)
bower(1)
bundle(2)
cache(1)
capistrano(2)
capistrano3(2)
centos(4)
chrome-extension(1)
crontab(1)
css(1)
curl(1)
data(2)
deploy(2)
dlj(1)
dropbox(3)
elasticsearch(1)
fqa(1)
gem(7)
geobean(1)
gfw(1)
gis(1)
git(4)
github(2)
gitlib(1)
google(1)
httpd(1)
iOS(2)
java(1)
javascript(2)
jekyll(1)
js(2)
letsencrypt(1)
linode(2)
linux(16)
memcached(1)
mongodb(5)
mongoid(2)
mongomapper(1)
mtr(1)
mysql(2)
newrelic(1)
nginx(7)
nodejs(1)
notejs(1)
observer(1)
octopress(1)
omniauth-oauth(1)
openlayers(1)
paginate(2)
passenger(2)
pipeline(1)
plugin(2)
production(1)
proxy(3)
rails(23)
rails3(4)
rake(1)
restful_authentication(1)
ruby(28)
rvm(6)
search(1)
siege(1)
sinatra(2)
skill(7)
socks(1)
solr(1)
sql(2)
sqlserver(1)
ssh(6)
ssl(1)
story(4)
sublime-text(3)
sunspot(1)
sweeper(1)
theme(1)
tile(1)
tools(1)
ubuntu(19)
vagrantbox(2)
vps(2)
web(1)
webkit(1)
webpack(1)
win(3)
xcode(2)
yarn(1)
yum(1)
佛(3)
创业(1)
压力测试(2)
正则(1)
转载(7)