Using Git in Idea IntelliJ

The example shows how to work with a version control such as GIT.
1. First of all, you need to create an account, for example on github.

2. Next, you need to create a new repository.

3. Next in Idea. VCS – Checkout from Version Control – Github

4. Fill login / password.

5. Commit

6. Fill Commit message. Press Commit

7. If you are working in the same project as a team, you must first pull the last changes from the repository – Pull.

8. If there were no changes, you can now put your project on the server – Push.

9. Push Successful.

10. Checking in the repository.

Excluding files and directories from the repository.
Sometimes you need to exclude packages and files from push to git, such as logs, confidential information, maven configs, or the environment itself. Let’s look at an example when files have already been pushed to the repository and need to be excluded.

A file is created in the root of the project .gitignore

File contents. Exclude files, categories, gitignore itself from our comit.

### JetBrains template
# Mac
# Maven

Terminal commands

Create gitignore file
touch .gitignore

Add record in gitignore
echo “.idea”> .gitignore

Remove files.
git rm -r -f –cached .
git rm –cached –ignore-unmatch -r — *

git add .

Commit & Push
git commit -m “update project and remove files”
git push -u origin master

Releated Post