如何完成这种push

有一个文件夹 mydoc
里面有些涉及密码的东西,每次我push前,就将mydoc里面所有涉及密码的地方,改成xxxx
然后通过
git add .
git commit -m "new"
git push -u origin master

push完成后,我再将xxxx换成实际的密码,因为这个mydoc在我本机需要实际使用的。

感觉很麻烦,于是
cp -r mydoc /tmp
然后对tmp里面的文件,替换密码后,使用

git add .
git commit -m "new"
git push -u origin master
报错:

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.

请问,应当如何解决?

阅读 1.6k
2 个回答

密码为什么会记在文档中?

这个密码可以考虑存储在本机的环境变量里。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进