Compiled from the “Development Tips” series, gathering practices around Git collaboration and development environment setup.
1. warning: LF will be replaced by CRLF
Windows, Linux, and Mac are inconsistent in how they mark line endings in files. Windows uses CRLF as the terminator, while Linux and Mac use LF.
Git has two modes for handling line endings. Check the Git configuration.
| |
If it shows true, then every time you run git commit, if a text file is present, Git will automatically convert the trailing line ending to CRLF for you, saving you the annoying conversion work.
If it shows false, Git will not modify the line endings and keeps the original content.
For Linux and Mac developers, this setting should be false, while for Windows developers it should be set to true.
| |
2. How to Merge Two Fork Repositories
View the local remotes:
| |
Add the remote to be merged:
| |
View the local remotes:
| |
Fetch the latest updates from the remote:
| |
Merge the remote fork branch into the current branch:
| |
3. Doing Git Development Based on Tags
Create a branch from a tag:
| |
In fact, branch can be a branch, a tag, or even a commit id.
Switch to the newly created branch:
| |
View the committer’s username and email information:
| |
Push the newly created branch to the remote:
| |
4. Setting Git Access Credentials on Linux
Windows and OS X have keychain tools that manage account credentials, but on Linux systems, when accessing a Git repository over the Http/Https protocol, you have to enter the account password every time. The configuration below lets you skip that step.
- Create a credentials file
| |
- Edit the file and add the credential information
| |
- Make the credentials take effect
| |
Once done, the Git configuration file ~/.gitconfig will be generated.
cat ~/.gitconfig
[user]
email = yourmail
name = yourname
[credential]
helper = store
5. Using pipenv
- Pipfile
Pipfile is a community-proposed dependency management file intended to replace requirements.txt. Pipfile.lock records the version numbers and hashes installed in the current environment.
- Install
| |
- Create an environment
| |
The interpreter here needs to already be installed locally, and it does not have to be added to the PATH environment variable.
- Enter the environment
| |
6. pipenv Should Be Used Together with pyenv
pipenv can manage a project’s dependency environment, isolating each project.
| |
pipenv can also manage interpreters, allowing you to specify the Python version.
| |
When you run the commands above, pipenv first looks for a suitable version on the system. If it does not find one and pyenv is installed, pipenv will automatically call pyenv to download the corresponding version of the Python interpreter.
If pyenv is not installed, pipenv will only report that no matching version was found. Therefore, when using pipenv, it is best to use it together with pyenv.
7. Quickly Setting Up a Development Environment on Windows
After upgrading my work PC’s operating system to Windows 10, here are the steps I use to quickly set up a Python development environment:
With administrator privileges, run in CMD:
| |
Create a new file packages.config with the following content:
| |
Run the command to install the software:
| |
Add the C:\tools\msys64\usr\bin directory to PATH, and download the VS Code configuration from gist, and then you basically have all the development software you need.
The Console I mainly use is Powershell; running bash gets you into msys2.
8. How to Start the Portable Version of MySQL on Windows
Edit the configuration file my.ini:
| |
Add skip-grant-tables to skip the restriction of the privilege tables, so you can log in directly without verifying the password.
Register MySQL as a system service
| |
Start MySQL
| |
9. How to Register MongoDB as a Windows Service
After downloading and installing, add the directory C:\Program Files\MongoDB\Server\4.0\bin\ to PATH.
Run the command with administrator privileges:
| |
Start the MongoDB service:
| |
