This chapter will teach you how to work with Git and GitHub, from the basics to authenticating and interacting with your own repositories. It explains statuses in invitations, basic and advanced Git features, and walks you through working with sample and task repositories. It’s the perfect introduction for those who want to feel confident using modern team development tools.
1. Preparation for work
In order to start working with Python, you need to decide on a few things:
what operating system will be used;
what editor will be used;
what version of Python will be used.
The book uses Debian Linux (output may vary on other OSes) and Python 3.7.
Another important point is the choice of editor. The next section provides examples of editors for different operating systems. You can use an IDE instead of an editor. IDEs are a good thing, but you shouldn’t switch to an IDE because of things like:
code highlighting;
syntax hints;
automatic indentation (important for Python).
All of this is available in any good editor, but you may need to install additional modules to get it. At first, you may find that the IDE is just too distracting with its many features. You can see a list of IDEs for Python here. For example, you can choose PyCharm or Spyder for Windows.
2. Using Git and GitHub
There are a lot of tasks in the book and you need to store them somewhere. One option is to use Git and GitHub for this. Of course, you can use other tools for this, but using GitHub, you can gradually figure it out and then use it for other tasks. The tasks and examples of the book are in a separate repository on GitHub. They can be downloaded as a zip archive, but it is better to work with the repository using Git, then you will be able to see the changes made and easily update the repository. If you are learning Git from scratch and especially if this is the first version control system you are working with, the information can be very much, so this section is all focused on the practical side of the issue, and tells:
how to get started with Git and GitHub;
how to perform basic configuration;
how to view information and/or changes.
There will be little theory in this section, but links to useful resources will be provided. Try to first do all the basic settings for performing tasks, and then read the book. And at the end, when basic work with Git and GitHub is already familiar, read about them in more detail. What can Git be useful for:
to store configurations and all changes to them;
to store documentation and its versions;
to store schematics and all their versions;
to store code and its versions.
GitHub allows you to centrally store all of the above, but keep in mind that these resources will be accessible to others. GitHub also has private repositories, but even there you shouldn’t post information like passwords.
Git Basics
Git is a widely used distributed version control system (VCS) released under the GNU GPL v2 license. It can:
track changes to files;
save multiple versions of the same file;
undo changes;
record who made changes and when.
Git stores changes as a snapshot of the entire repository. This snapshot is taken after each commit.
Installing Git:
$ sudo apt-get install git
Initial Git setup
To start working with Git, you need to specify the user name and email address that will be used to synchronize the local repository with the repository on GitHub:
Repository initialization is performed using the git init command:
[~/tools/first_repo]
$ git init
Initialized empty Git repository in /home/vagrant/tools/first_repo/.git/
After executing this command, a .git folder is created in the current directory, which contains the service files required by Git.
Displaying repository status in invitation
This is additional functionality that is not required for working with Git, but it helps a lot. When working with Git, it is very convenient to be able to immediately determine whether you are in a regular directory or in a Git repository. In addition, it would be good to understand the status of the current repository. To do this, you need to install a special utility that will show the status of the repository. To install the utility, you need to copy its repository to the home directory of the user under whom you are working:
In this article, you will learn how to effectively use the capabilities of the language for working with files in the daily practice of a network specialist.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.