Git: how to modify a specified commit?

Question:

I usually submit a list of commits for review, so I have a problem:
If I have commit1, commit2, commit3, head.
I know that I can modify head commit with git commit --amend, but how can I modify commit1 that is not head commit.

Result:

You can use git rebase, for example, if you want to modify commit bbc643cd, run

$ git rebase bbc643cd^ --interactive 

In the default editor, modify ‘pick’ to ‘edit’ in the line whose commit you want to modify. Make your changes and then stage them with

$ git add <filepattern> 

Now you can use

$ git commit --amend 

if you need to modify/update the commit author, you should waived the above command, and invoke the below command:

$ git commit --amend --author="new user name <email@adress.com>" 

to modify the commit, and after that

$ git rebase --continue 
to return back to the previous head commit.
Reference:
http://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit

使用 git send-email 发送patch

今天折腾了下git send-email, 我以gmail为例。
首先, 安装git 和 git-email包 (git send-email功能不包含在git包中, 它包含在git-email中)
$ sudo yum install git git-email -y
下来 配置git环境变量, 建议使用git config配置(不过, 你完全可以直接编写~/.gitconfig)
$ git config –global user.name your_name
$ git config –global user.emal your_email
$ git config --global sendemail.smtpserver smtp.gmail.com
$ git config --global sendemail.smtpserverport 587
$ git config --global sendemail.smtpencryption tls
$ git config --global sendemail.smtpuser email_user
okay, 下来你就使用 git send-email发送patch, 按照提示填写from, to, passwd等信息
$ git send-email your_patch_file.patch …
如果 你的from 和 to域比较固定,上一操作 完全可以省略:
$ git config –global sendemail.smtppass your_email_passwd
$git config –global sendemail.from “name <*@*>”
$git config –global sendemail.to “name <*@*>”
git config –global的信息全部写入~/.gitconfig文件中,你可以手动修改该文件

Mysql 备份 于 恢复

转: http://blog.csdn.net/feng_sundy/article/details/3496744

逻辑备份:
1.mysqldump(数据导出工具)
mysqldump options db_name[table_name]//备份单个数据库
mysqldump 选项 –database database-name1 [databases-name2]….//备份指定的数据库一个或者多个
mysqldump 选项 –all-database //备份所有的数据库
链接选项:
-u :指定用户名
-p:指定密码
-h:指定服务器ip或者域名
-P(大写):指定端口
eg:/usr/bin/mysqldump -u root -h 202.194.132.237 -P 3306 -p BBS user>/home/wuxiaoxiao/user.txt
输出内容选项:
–add-drop-database:每个数据库创建语句之前加上drop database语句
–add-drop-table:每个表创建语句之前加上drop table语句
-n:不包含数据库的创建语句
-t:不包含数据表的创建语句
-d:不包含数据
输出格式选项:
–compact:使输出结果简洁
-c –compact-insert:使输出文件中的insert语句包含字段名
-T:将数据库表中的数据备份为单纯的数据文本和建表sql俩个文件
–fields-terminated-by=name(域分割符)
–fields-enclosed-by=name(域引用符)
–fields-optionally-enclosed-by=name(域可选引用符)
–fields-escaped-by=name(转移字符)
eg:/usr/bin/mysqldump -u root -h 202.194.132.237 -P 3306 -p BBS user -T ./bak
字符集选项:
–default-character-set=name:设置导出的客户端字符集
eg:mysql -u root -p –compact –default-character-set=utf8 BBS user > test.txt
其他选项:
-F:备份前刷新日志
-l:给所有表加读锁(备份期间使用,使备份的数据保持一致性)

备份:
备份所有数据库:
mysqldump -u root -p  –all-database  >  test.sql
备份数据库test
mysqldump -u root -p  test  >  test.sql
备份数据库test下的temp表:
mysqldump -u root -p  test demp >  test.sql
备份数据库下的所有表为逗号分割的文本,备份到/temp
mysqldump -u root -p test -T /temp –fields-terminated-by ‘,’
完全恢复:
msyql -u root -p < bakfile
注意:将备份恢复后数据并不完整,还需要将备份后执行的日志进行重做
mysqlbinlog binlog-file | mysql -u root -p***
举个完整的mysqldump备份和恢复的例子:
上午9点备份数据库
mysqldump -u root -p -l -F test > test.dmp
9点半备份完毕,然后想数据库中插入数据
10点数据库突然故障,数据无法访问,需要恢复备份
mysql -u root -p test < test.dmp
恢复后的数据并不完整,9点半插入的数据并没有恢复
使用mysqlbinlog恢复自mysqldump备份以来的binlog
mysqlbinlog binlogfilename | mysql -u root -p test
基于时间点恢复:
如果上午10点发生了误操作.可以用下面语句进行备份和binlog将数据库恢复到故障前:
mysqlbinlog –stop-date=”2005-04-20 9:59:59″ binlogfile | mysql -u root -p test
跳过故障的时间点,继续执行后面的binlog,完成恢复
mysqlbinlog –start-date=”2005-04-20 9:59:59″ binlogfile | mysql -u root -p test
基于位置恢复:
mysqlbinlog –start-date=”2005-04-20 9:55:59″ –stop-date=”2005-04-20 10:05:00″ binlogfile > test.sql
查看此文件,找出出错语句前后的位置号,例如是368312,368315
mysqlbinlog –stop-position=”368312″ binlogfile | mysql -u root -p test
mysqlbinlog –start-position=”368315″ binlogfile | mysql -u root -p test

表的导入和导出:
导出:
mysqldump -u username -p -T target_dir dbname tablename [options]
options:
–fields-terminated-by=name(域分割符)
–fields-enclosed-by=name(域引用符)
–fields-optionally-enclosed-by=name(域可选引用符)
–fields-escaped-by=name(转移字符)
备份数据库下的所有表为逗号分割的文本,备份到/temp
mysqldump -u root -p -T /temp test –fields-terminated-by ‘,’ –fields-optionally-enclosed-by ‘”‘
导入:
msyqlimport -u root -p [LOCAL] dbname order_tab.txt [options]
OPTIONS:
–fields-terminated-by=name(域分割符)
–fields-enclosed-by=name(域引用符)
–fields-optionally-enclosed-by=name(域可选引用符)
–fields-escaped-by=name(转移字符)
eg:mysqlimport -u root -p test order.txt –fields-terminated-by=’,’ –fields-enclosed-by=’”‘

RHEL6 搭建 本地 wordpress

由于之前的个人网站服务器done掉了,不能再写博客了,所以暂时搭建一个本地wordpress个人网站,可是在配置过程中,发现rhel6本身 自带的mysql不能满足需要,也许是由于mysql被oracle收购的缘由吧,使用mysql不像以前那样自由了,不过不用担心,按照一下步骤,你可 以简单轻松搞定mysql.

第一步: 移除mysql 和 mysql-libs
yum erase mysql
yum erase mysql-libs

第二步: 去官网下载mysql所需的rpm安装包(记得要先注册 才可以下载)
我是x86_64机器,我下载这些安装包:
[zliu@ZhoupingLiu mysql]$ ls
MySQL-client-5.5.17-1.linux2.6.x86_64.rpm
MySQL-devel-5.5.17-1.linux2.6.x86_64.rpm
MySQL-server-5.5.17-1.linux2.6.x86_64.rpm
MySQL-shared-5.5.17-1.linux2.6.x86_64.rpm
MySQL-shared-compat-5.5.17-1.linux2.6.x86_64.rpm
安装以上所有包,然后你就可以使用mysql了。
参考: http://server.billhamilton.com:84/wp/mysql/installing-mysql-5-5-11-on-rhel6-in-4-steps/
mysql搞定了,要完成wordpress的安装,还需要apache服务器,因此,你要安装httpd服务器: #yun install httpd & # service httpd restart
下来你还需要安装php-mysql这个包: #yum install php-mysql -y
到此所需要的环境基本具备,下来你要做的就是下载wordpress

http://wordpress.org/download/

将wordpress放在apache服务器目录下:
# move wordpress /var/www/htmls/
然后修改wp-config.php文件或者直接登录http://localhost/wordpress/wp-admin/install.php。
在做此操作之前,你要提供给wordpress一个数据库,访问该数据库的用户和密码,然后就是数据库的服务器地址,若本地就是localhost了。
mysql具体操作, 请参考:

* 注意 * 如果你在访问wordpress,遇到没有“权限”问题时,你需要关闭你的selinux:# setenforce 0
到此,结束。