
In this article, we will discuss various Git teams that may be useful for a developer or Big Data specialist. You will learn how to check, delete, and clean up the code. We will also consider ways to exit Vim and save time using Bash aliases and the Git editor configuration.
Skillbox recommends: Practical course "Mobile Developer PRO" .
We remind: for all readers of "Habr" - a discount of 10,000 rubles when recording for any Skillbox course on the promotional code "Habr".
We check everything and everyone

')
- git diff - View all file changes locally. When you specify a file name, the changes will be shown only for it.
- git log - View commit history. It can also be used for a file with git log -p my_file. Enter q to exit.
- git blame my_file - See who, what and when changed in my_file.
- git reflog - Show change log in local repository header. A great option to search for lost data.
These commands allow you to quickly check everything you need without any problems. If something is wrong, Git gives you plenty of opportunities to delete or revert commits and changes to files.
Return as it was
- git reset, git checkout and git revert are commands that are used to undo any actions. But they are not so simple, they must be able to handle them.
- git reset, git checkout can be used both for commits and for regular files.
- git revert is used only for working with commits.
If you work with your own local commits that are not related to team work, you can easily use all the listed commands.
If you work in a team and commits are common, then your choice is git revert.

Each team has a whole set of options. Here are the most used:
git reset --hard HEAD - cancel indexed and non-indexed changes since the last commit.
Instead of HEAD, we specify a specific commit to undo the changes that occurred after it. --hard discards both types of changes mentioned above.
Do not forget to make sure that you do not cancel the commit from the published branch, on which other members of the team depend.
git checkout my_commit - discard changes my_commit.
HEAD is often used for my_commit to discard changes in your local working directory since the last commit.
checkout is best used for local cancellations. In this case, commits from the remote branch, on which your colleagues depend, will not be affected!
If you use checkout with a branch instead of a commit, HEAD switches to the specified branch, and the working directory is updated to reflect the changes. This is the most common use of this command.
git revert my_commit - cancel the effects of changes in my_commit. revert performs a new commit after undoing changes.
revert is safe for common projects, as the team does not overwrite changes that other threads may depend on.

Sometimes you just want to delete untracked files in your local directory. For example, by running some code that created many different types of files that you do not need. Unfortunately. Clean will help to remove them instantly!
git clean -n - deletes untracked files in a local working directory.
-n - flag for test run, nothing is removed.
-f - flag to delete files.
-d - flag to remove untracked directories.
By default, untracked .gitignore files will not be deleted, but this can be changed.

Direct orders
git commit --amend - add incremental changes to the last commit.
If nothing is indexed, the command allows you to edit the last message of the commit. Use the command only if the commit was not merged with the remote master branch.
git push my_remote - tags - send local tags to remote repository. A good option for assigning versions of changes.
Help, I'm stuck in Vim and can't get out!
Git in some cases opens a Vim editor session. And if you are not too familiar with it, you may find yourself in a difficult situation. And not only you - for example, on Stack Overflow over 4 thousand users want to know how to get out of Vim.

Here is a four-step plan that will help close Vim and save the changes:
- Push i.
- Enter the commit message in the first line.
- Esc.
- Enter: x.
All you are free!
Change the default editor.
You can get rid of Vim completely if you change the default editor. Here are the
commands for working with popular editors. An example of choosing another editor, in our case Atom:
git config - global core.editor "atom - wait"
Shortcuts to git commands
And here is a way that allows you to add shortcuts for Git commands to your .bash_profile.
alias gs='git status ' alias ga='git add ' alias gaa='git add -A ' alias gb='git branch ' alias gc='git commit ' alias gcm='git commit -m ' alias go='git checkout '
More information about .bash_profile can be found
here .
As for the method above, you can now use gs instead of git status.
Actually, that's all for today. If possible, indicate in the comments which Git commands you use and why.
Skillbox recommends: