Skip to content

Latest commit

 

History

History
178 lines (124 loc) · 2.98 KB

File metadata and controls

178 lines (124 loc) · 2.98 KB

It's the first homework for Git seminar

What is a Git?

Git is a free and open source distributed version control system


Common Git commands


Let's try to describe some commands that we have learned


git config

Set the name John Doe and email john_d_email@mail.com that will be attached to commits and tags.

git config --global user.name "John Doe"
git config --global user.email "john_d_email@mail.com"

top


git init

Create a local repo in directory. If omit directory current directory will be initialised as repo.

git init <directory>

top


git add

Add file content to the index.

Add all files in directory if used the dot .

git add <file>
git add .

top


git commit

Commit all added files to index with comment.

git commit -m <comment>

top


git status

Show working tree status — differences between the index file and the current HEAD commit.

git status 

top


git log

Show the commit logs.

git log

top


Branches, git branch and other ways for branch creating and swiching

git branch [options]

Create, list or delete branches. WIth branch_name create this branch. Full optoins list is here.

Create branch branch_name

git branch <branch_name>

Alternate ways:

Fast creation and checkout

git checkout -b <newbranchname>

New (from Git 2.23)

Now, from Git version 2.23, we have a new command for branch changing and creating.

Changing branch to some_branch:

git switch <some_branch>

Creating and changing to new_branch:

git switch -c <new_branch>

top


git checkout

Switch to a branch branch_name and update the working directory

git checkout <branch_name>

Or create a new branch branch_name and switch to it.

git checkout -b <branch_name>

top


Merging

You or somebody else made work on some part of project and now it's need to add this part in our project. For this you have to use something like this (merge added_branch to current:

git merge <added_branch>

top


Conflicts in merging

Sometimes merging has problems.

add some humor about merging

top