为了自动给blog备份,我把blog放在dropbox里面,这样主机和vmware上的ubuntu_dl机器可以同步,而且dropbox在线还有一份,这样不同意丢了。即使不小心删掉也会有online的备份。
可是一个问题是老是会出现git的error,比如
hhh@ubuntu:~/Dropbox/blog/output$ git commit -m "test"
error: object file .git/objects/d2/f4c036db03671b6d859b137e4ccdc06383fb14 is empty
error: object file .git/objects/d2/f4c036db03671b6d859b137e4ccdc06383fb14 is empty
fatal: loose object d2f4c036db03671b6d859b137e4ccdc06383fb14 (stored in .git/objects/d2/f4c036db03671b6d859b137e4ccdc06383fb14) is corrupt
hhh@ubuntu:~/Dropbox/blog/output$ git commit -m "test"
fatal: could not parse HEAD
好像是.git
下面的文件因为dropbox同步什么的出现了问题。解决的办法也很简单。
- 到
blog/output
文件夹,cd output
, 删掉里面的.git
文件夹rm -rf .git
clone github
的文件git clone git@github.com:songhuiming/songhuiming.github.io.git
- 这个时候在
output
文件夹下面会出现文件夹songhuiming.github.io
- 把
songhuiming.github.io
里面的.git
文件夹复制到output
下面,cp -rf songhuiming.github.io/.git .
- 删掉文件夹
songhuiming.github.io
- 重新到
blog
文件夹下面make html
然后就可以正常git commit
和git push
了
pip install -e .
to install a package
mypackage
folder has the following tree structure:
.
├── Config
├── __init__.py
├── README.md
├── setup.py
├── .gitignore
└── src
├── basecode
│ ├── aws
│ │ └── aws.py
│ ├── dataprocess
│ │ └── dataprocess.py
│ └── utils_old
│ ├── old.py
│ ├── temp.py
│ └── utils.py
└── mypackage.egg-info
├── dependency_links.txt
└── top_level.txt
setup.py
from setuptools import setup, find_packages
setup(
name='mypackage',
version='0.1',
packages=find_packages(where="src", exclude=("test",)),
package_dir={"": "src"},
entry_points={
'console_scripts': [
'pwd=basecode.sys.sysos:print',
],
},
)
.gitignore
.gitignore
src/basecode/utils_old
mypackage.egg-info
git
四个区域: 硬盘 /(git add →) 暂存区 / (git commit → ) local / (git push →) remote
git clone xxx
git checkout -b mybranch
# create my own branch- code change, bala bala
git diff
# check what I changedgit add .
# add code to stage 暂存区- `git commit -m "xx"`` # commit to local.
git push origin mybranch
# push to remove mybranch- 但是在push的时候,可能remote的master已经有人更改代码了。这个时候要把remote最新的变化跟我的代码变化merge起来
git checkout master
# 切换到master branchgit pull origin master
# pull remote的代码到 local 和 本地硬盘git rebase master
# 把我的修改放一边,把remote的代码拿过来,然后再尝试把我的修改的代码弄进去到master(注意,不是merge,尽管最后结果是把两个code merge成最终版本)。这个时候可能有rebase conflict,需要手动解决; reapply the commits from your current branch on top of the master branch. It effectively changes the base of your branch to the latest commit in master.git push -f origin mybranch
# 需要 -f 来强制pushpull request
, remote code owner will dosquash and merge
git remote -v
# check remotegit remote add share $(git config remote.origin.url)/share/shmtest
# create remote share/shmtestgit push share shmtest
# push to the remote sharegit push share HEAD
# if I don't have permission so I cannot push my changes there; another to push current branch (shmtest) to remote share