(Quantum) $ git init Figure 3 – Initialising an empty Git Repository inside the Quantum virtual environment. Note that we have both activated the VE and we have navigated to inside the folder before executing the Git initialisation. Change directory to this folder to view the basic skeleton structure of an empty Git Repo: git folder inside the Quantum virtual environment folder structure. We now need to add the Quantum VE to the gitignore git/ Figure 4 – The folder structure of an empty git repo. (Quantum) $ pip freeze > requirements.txt Now type in the following to create a dependency file: This keeps the virtual environment out of source control. This will also create a new text file inside the ~/py_envs/Quantum/.git folder. Figure 5 – Creation of the requirements text file, i.e. If you have vim installed, you can view the text file in Terminal with either the folder which contains all of the dependencies. We can force Git to track all of our files by typing in (Quantum) $ git status Figure 8 – Note the green text at the top indicating that there is a new file to commit to the repo! Let’s add our pip requirements (dependencies) file to this repo with the command: This is correctly showing the list of Python source files that it is keeping track of! (Quantum) : ~/py_envs/Quantum$ git status Figure 7 – Checking the Git Status (Quantum) $ nano requirements.txt Figure 6 – Opening the requirements text file shows a list of all the dependencies of your Virtual Environment.Ĭlose the text editor and go back one directory to the Quantum VE folder. This won’t work, because now git wants to track all the files in the VE, including Python’s site packages! According to my environment, that is over 19,000 files! Git Reset (Quantum) $ git status Figure 9 – Argh! Now all of our files are added and being checked for updates in the Git repo! That’s way too many, we just want our Python files (which you can see at the end there). To check that it has un-added all the files. Let us check in the files we need one-by-one. (Quantum) $ git config -global user.email $ git config -global user.name "yourname" It shows the requirements text file as a change to be committed. We can also view this change in the Git log by typing in: (Quantum) $ git commit -m 'Added requirements.txt' Figure 10 – Added a single Requirements text file to git repo. #Gitkraken could not connect to origin install.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |