sudo apt install git
https://git-scm.com/download/linux
.gitignore - Specifies intentionally untracked files to ignore
.gitconfig - Define the author name to be used for all commits in the current repository.
git config --global user.name "Billy Bob"
git config --global user.email "b.bob.domain.com"
git config -l # Show config
mkdir gitproject01
cd gitproject01
git init . # Create an empty Git repository or reinitialize an existing one
git status # Show the working tree status
git add . # Add new file to the index
git commit -m "version 1" # Record changes to the repository
git log # Show commit logs
git log -2 -p # Show diff, -2 - Show last 2 commit, -p show detailed information
git checkout -- file # cancel changes for file (before git add)
git diff --cached # View the changes you staged for the next commit
git checkout 2sd3hsk4dfhskjfh8 # Switch to sdkfhskdfhskjfh8 commit
git checkout master # Switch to last commit
git reset --hard HEAD~3 # Delete last 3 commite
git reset --soft HEAD~3 # Delete first 3 commite
git commit --amend # Edit a past commit, without commits
git clone https://github.com/repos.git
# Make changes
git add .
git commit -m "version 1"
git push origin
# Enter user/ pass
git remote -v # Manage set of tracked repositories, -v - verbose
Make keys
ssh-keygen
Send .pub key to github (Settings > SSH and GPG keys > New SSH key)
Switch HTTPS to the SSH
git remote set-url origin git@github.com:repos.git
git branch # Existing branches are listed
git branch branch_name # Create the new branch, but it will not switch the working tree to it
git switch branch_name # To switch to the new branch
git checkout branch_name # The same
git checkout -b branch_name # Create branch and switch to the new branch
git merge branch_name # Join two or more development histories together, master should be current branch
git branch -d branch_name # Delete a branch (after merge, -D when without merge)
git push origin --delete branch_name # Delete remote branch
git clone git@github.com:repos.git
cd repos
git branch
git checkout -b my_branch
# Make changes
git add .
git commit -m "some changes"
git push --set-upstream origin my_branch # Make my_branch in remote repository and load changes
git tag # Show all tags
git tag v1.1.0 # Make a tag
git push origin v1.1.0 # Push a tag
git checkout v1.1.0 # switch to v1.1.0, uses instead of branch_name