1.仓库问题
github中新建仓库 clone至本地后,删除github 上的仓库 ,再次新建同名仓库,在本地提交会出现:
To https://github.com/yourname/Interview.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/yourname/Interview.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
本地仓库和GitHub上的仓库会被认为两个独立的仓库,可使用如下命令解决:
$ git pull origin master --allow-unrelated-histories
2.私搭仓库
在linux上使用
sudo git init --bare example.git
建仓
结束后在本地clone ,添加文件,add commit push 后想在服务器上找到提交的文件,没找到,网上查阅后,得知,使用–bare参数时,服务器此仓库只是负责记录提交记录的和元数据,不记录提交文件,想在服务器上查看文件,可以找一个喜欢的文件夹,使用
git clone /you/repository/path
cd youdir
git pull
然后就可以看到提交的文件了