Git and team development
Hello! If you came here, then you are interested in the question of how programmers work in a team. If before you worked only in solo, then it probably seems to you that working in a team is easier, because there are more hands and that means you can do the job much faster. But everything here is not so simple. Now we will familiarize ourselves with what tools are being developed and what is happening inside the team.
Git
Surely you are familiar with a versioning issue. Typically, such a problem occurs in creative people who constantly redo everything and achieve the ideal. Unfortunately, in programming, too, far from always everything turns out right the first time. Imagine a situation: you figured out how to redo some piece of code so that it works a little faster. You rewrite, compile, run, and understand that now the program does not work at all. Everything is broken.
And here you realize that you have not saved the working option, and the Z button on your keyboard has broken, so you can not even spam ctrl + z. Possible, right now you break through the monitor with your pumped right hand. In the evening, you cry, wrapped in a blanket, and think about the dramatic destiny of programmers.
A deplorable situation … And to prevent this from happening, you need to save versions of your code.
Well, programmers are smart people, and they perfectly understood that storing all versions in the form of a heap of files is not convenient as much as possible and that you urgently need to come up with something that will facilitate the storage of versions and thereby solve the versioning problem.
And here we can draw an analogy with games. Almost all AAA projects have a save system. As a good example, the game Papers Please.
Proximately the same, all version control systems work.
Version Control System (VCS) is a system that records changes to a file or set of files over a long period of time, so that you can later return to a specific version.
VCS classification:
- Local
- Centralized
- Distributed
We already figured out what the local VCS is (these are the same heaps of identical files).
Centralized VCS
- central server
- all files under version control
- a number of clients
- receive copies of files
Examples:
- CVS
- Subversion
- Perforce
Distributed VCS
- Clients fully copy the entire repository
- The central server is responsible for providing the master copy
- Synchronization with server/any client
Examples:
- Git
- Mercurial
- Bazaar
Why do I need VCS
- Storing all project changes
- The ability to switch “to any stage of the project”
- The ability to conduct simultaneous team development
- Ability to solve popular team problems
Git
Git – Distributed Version Control System
Author: Linus Torvalds
2005 – first version
Installation:
Linux: sudo apt install git
Windows / macOS: https://git-scm.com/download/
For developers, which use:
- GNU / Linux
- Android
- Wine
- Chromium
- jQuery
- Php
- MediaWiki
Qt
Basic concepts
Repository (repository, repo) – a place where VCS stores its metadata and a database of project objects
Working directory – a copy of a specific version of a project extracted from the repository
Staged area– a service file containing information about what should be included in the next revision of the project
Revision – an object that stores the change in the state of the project (version of the project)
Commit – creating a new revision
Configuration of GIT
Username Setting
1 2 |
git config --global user.name "Your Name" |
1 2 |
git config --global user.email [email protected] |
Settings are saved in a hidden .gitconfig file (in the user’s home directory)
[user]
name = John Doe
email = [email protected]
Creation of Repository
1 2 |
mkdir first_git_repo |
1 2 |
cd first_git_repo |
1 |
git init |
Project File Statuses
Fixed
the file is already in the repository
Modified
the file is different in content from its committed state
Prepared
a modified file that will become committed after creating a new revision (this file will go into this revision)
Work with code
Repository Initialization
1 |
git init |
Or switching to a specific revision
1 2 |
git checkout revision number |
- Change in project code: creating / deleting / editing files
In any IDE
- View Status
1 |
git status |
- Adding Modified Files to the Index
(transition to the state of Staged)
1 2 |
git add filenames through space |
- Creating a revision (from Staged to Repo)
1 2 |
git commit -m "Comment" |
Related Posts
Leave a Reply Cancel reply
Service
Categories
- DEVELOPMENT (103)
- DEVOPS (53)
- FRAMEWORKS (25)
- IT (25)
- QA (14)
- SECURITY (13)
- SOFTWARE (13)
- UI/UX (6)
- Uncategorized (8)