Repo,git,svn代码回滚,强制同步

repo:

Android ROM开发经常使用repo sync。有时候有些project因为调试的原因做了一些改动,sync下来就和远程不同步了。
参考了repo的代码(.repo/repo/subcmds/sync.py)里有个参数:
p.add_option(‘-d’, ‘–detach’,
dest=’detach_head’, action=’store_true’,
help=’detach projects back to manifest revision’)
repo sync -d会将HEAD强制指向manifest的库,而忽略本地的改动。
所以比较安全的做法是
先确认本地改动没必要保存了,确认之前不妨用分支备份一下(git checkout -b backup_branch; git add -u; git commit)

或者用笨办法,直接用cp备份一下,然后:

repo sync -d
repo forall -c ‘git reset –hard’ # Remove all working directory (and staged) changes.
repo forall -c ‘git clean -f -d’ # Clean untracked files

强制与远程服务器同步,会删除对服务器文件的修改,但是不会删除添加到目录的新文件
repo forall -c git reset --hard HEAD
删除新添加的文件
repo forall -c git clean -xfd

SVN:

丢弃对一个文件的修改:
$ Svn revert foo.c
Reverted foo.c
如果你希望恢复一整个目录的文件,可以使用--depth=infinity选项:
$ Svn revert --depth=infinity .
Reverted newdir/afile
Reverted foo.c
Reverted bar.txt
最后,你可以取消预定的操作:
$ svn add mistake.txt whoops
A         mistake.txt
A         whoops
A         whoops/oopsie.c
$ Svn revert mistake.txt whoops
Reverted mistake.txt
Reverted whoops
$ svn status
?      mistake.txt
?      whoops。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值