git中出现“non-fast-forward”errors时的终极解决方案

如果你是个git新手,通过网上那一页教程学会了使用git bash将自己的项目push到远端repository。那么你一定遇到过如下的问题:
non-fast-forward

error: failed to push some refs to ‘ur repository’

而如果,你百度了这个问题,你将在百度的前三页搜索中得到完全相同的答案:

问题(Non-fast-forward)的出现原因在于:git仓库中已经有一部分代码,所以它不允许你直接把你的代码覆盖上去。于是你有2个选择方式:
1,强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容
git push -f

2,先把git的东西fetch到你本地然后merge后再push
$ git fetch
$ git merge

以上皆为狗屁

如果你真的照做了:
* 第一个方法会完全覆盖掉你之前的提交。如果你只是提交几个修改,那就真是得不偿失了。
* 第二个方法并没什么卵用。


终极解决方案

### Python 3.8 on Linux Installation and Configuration #### Installing Python 3.8 from Source Code For users who require a specific version of Python that is not available through the default package manager, installing directly from source code can be an effective method. To install Python 3.8 on Debian-based systems such as Ubuntu or Debian itself: Firstly, ensure all necessary dependencies are installed by executing `sudo apt-get update` followed by `sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ xz-utils tk-dev libffi-dev liblzma-dev python-openssl git`. After preparing the environment, download the desired Python release tarball using `wget https://www.python.org/ftp/python/3.8.x/Python-3.8.x.tgz`, replacing "x" with the latest minor version number[^1]. Unpack this archive via `tar xf Python-3.8.x.tgz`. Navigate into the extracted directory (`cd Python-3.8.x`) where compilation will take place after running configure script: `./configure --enable-optimizations`. Compilation starts once configured successfully: `make altinstall`. Note here to use `altinstall` instead of `install` command to prevent overwriting existing system-wide Python binaries. #### Setting Up Pip for Python 3.8 Once Python 3.8 has been properly set up, setting up pip becomes straightforward. One approach involves downloading the official bootstrap script provided by PyPA (Python Packaging Authority). Execute these commands sequentially within terminal session: ```bash curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3.8 get-pip.py ``` This process installs both pip along with its associated tools like setuptools which facilitate managing packages efficiently under Python environments specifically targeting Python 3.8 interpreter instance[^2]. #### Configuring Environment Variables Environment variables play crucial roles when it comes down to configuring software applications including interpreters like Python. For example, adding custom library paths ensures proper linking during runtime operations without causing conflicts between different versions residing simultaneously across filesystem hierarchies. Appending lines similar below at end part inside `.bashrc` file helps achieve seamless integration while avoiding potential issues caused by missing libraries or mismatched ABI interfaces: ```bash export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" source ~/.bashrc ``` Such configurations allow dynamically loaded modules access additional directories beyond standard locations defined originally upon installation phase thus enhancing flexibility significantly especially concerning third-party extensions requiring non-standard dependencies outside conventional search scope established initially[^3]. --related questions-- 1. What steps should one follow if encountering dependency errors during Python setup? 2. How does altering PATH variable influence execution priority among multiple Python installations coexisting side-by-side? 3. Can you explain how virtualenv works alongside global site-packages management strategies effectively? 4. In what scenarios would someone prefer compiling Python rather than utilizing precompiled binary distributions offered officially?
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值