官术网_书友最值得收藏!

  • Cloud Native Python
  • Manish Sethi
  • 446字
  • 2021-07-02 19:11:55

Getting familiar with the GitHub and Git commands

In this section, we will go through a list of Git commands, which we will be using frequently throughout the book:

  • git init: This command initializes your local repository once when you are setting it up for the first time
  • git remote add origin <server>: This command links your local <indexentry content="Git command:git remote add origin " dbid="164250" state="mod">directory to the remote server repository so that all the changes pushed are saved in the remote repository
  • git status: This command lists the files/directories that are yet to be added, or are modified and need to be committed
  • git add * or git add <filename>: This command adds files/directories so that <indexentry content="Git command:git add * or git add " dbid="164250" state="mod">they can be tracked, and makes them ready to be committed
  • git commit -m "Commit message": This command helps you commit your track changes in the local machine and generate the commit ID by which the updated code can be identified
  • git commit -am "Commit message": The only difference between the previous command and this command is that this opens a default editor to add the commit message based on an operating system such as Ubuntu (Vim) or Windows (Notepad++) after adding all the files to stage
  • git push origin master: This command pushes the last committed code from the local directory to the remote repository

Test everything to make sure our environment works.

Here we go. We have installed both Git and Python in the last section, which are needed to begin with building microservices. In this section, we will focus on testing the installed packages and try to get familiar with them.

The first thing we can do is to exercise the Git command, which fetches an external Python code from a repository (usually GitHub) over HTTPs, and copies it into our current workspace in the appropriate directory:

$ git clone https://github.com/PacktPublishing/Cloud-Native-
Python.git

The preceding command will create a directory named Cloud-Native-Python on your local machine; switch to the Cloud-Native-Python/chapter1 path from the current location.

We will need to install the requirements of the apps that are needed to run it. In this case, we just need the Flask module to be available:

$ cd hello.py
$ pip install requirements.txt

Here, Flask works as the web server; we will understand more about it in detail in the next chapter.

Once it is installed successfully, you can run the app using the following command:

$ python hello.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)  

I think we are good to see the output, which is as follows:

$ curl http://0.0.0.0:5000/
Hello World!  

If you see this output, then our Python development environment is correctly set up.

Now it's time to write some Python code!

主站蜘蛛池模板: 郸城县| 青河县| 木兰县| 天镇县| 馆陶县| 广东省| 青海省| 西乌珠穆沁旗| 西吉县| 玉林市| 庄浪县| 襄城县| 清新县| 温泉县| 斗六市| 吴堡县| 卢湾区| 伊川县| 襄樊市| 桂阳县| 福清市| 金华市| 鄂托克前旗| 开封县| 永春县| 故城县| 合阳县| 桂东县| 宣武区| 石泉县| 郸城县| 阳江市| 吴桥县| 庆云县| 咸阳市| 沭阳县| 乌鲁木齐市| 岳阳市| 图片| 扶沟县| 类乌齐县|