Github使用过程记录

0. clone repository:

git clone --recursive https://github.com/xqzhang2015/vimconfig



1. 添加/修改 文件

git add README.md
git status
git commit -m "modeify the README.md to add some commands"
git status
git push


2.添加submodule



3. github版本回滚

git log
git reset --hard 48e474a39781df681366247889a88b0c5beecc50
git status
git push -f
git status
重新修改并提交文件:

git add install.sh
git commit -m "more auto"
git push



3.修改文件记录

<span style="font-size:18px;">➜  vimconfig git:(master) ✗ git commit -m "modified vimrc configure file"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified:   .vimrc
modified:   vimrc


Untracked files:
.gitmodules.old


no changes added to commit
➜  vimconfig git:(master) ✗ git add .vimrc
➜  vimconfig git:(master) ✗ git add vimrc
➜  vimconfig git:(master) ✗ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)


modified:   .vimrc
modified:   vimrc


Untracked files:
  (use "git add <file>..." to include in what will be committed)


.gitmodules.old
==================================================
➜  vimconfig git:(master) ✗ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:


  git config --global push.default matching


To squelch this message and adopt the new behavior now, use:


  git config --global push.default simple


When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.


Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.


See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)


Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 653 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://github.com/xqzhang2015/vimconfig
   b59f60d..b7fa29d  master -> master
➜  vimconfig git:(master) ✗ git status </span>
 

<span style="font-size:18px;">[xqzhang@PEKdev032 ~/NHT201507/test_git/vimconfig]$ git pull -recurse-submoduleserror: did you mean `--recurse-submodules` (with two dashes ?)
[xqzhang@PEKdev032 ~/NHT201507/test_git/vimconfig]$ git pull --recurse-submodules</span>


【注】正常命令

git remote add origin https://github.com/zhchnchn/VimConfig.git
git push -u origin master


4.vimrc配置文件路径 使用脚本自动替换

[xqzhang@PEKdev032 ~/NHT201507/test_git/vimconfig]$ sed -i "s/PATH_VIM/${PATH_VIMCONFIG}/g" vimrc
sed: -e expression #1, char 13: unknown option to `s'

改为:

[xqzhang@PEKdev032 ~/NHT201507/test_git/vimconfig]$ sed -i "s%PATH_VIM%${PATH_VIMCONFIG}%g" vimrc

【注】问题解决参考资料

<span style="font-size:18px;">百思不得其解之下,我做了一些尝试,终于发现,如果使用“%”而不是“/”来作为sed的替换操作的分隔符,就不会出错。
代码如下:

#!/bin/sh

PWD=`pwd`
DEF_FILE="t1.def"

cat $DEF_FILE | sed "s%WKDIR=.*%WKDIR=$PWD%g" #> $DEF_FILE

exit 0

最后终于发现,问题就出在这个“/”,因为路径里面包含有“/”作为分隔符,这会和sed的替换操作的分隔符“/”引起混淆;所以,只要不使用“/”做分隔符就可以解决这个问题。</span>







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值