π¬π§ English | π«π· FranΓ§ais
git --version # show Git version
git --help # show help for Git commandsgit config --global user.name <name> # set global username
git config --global user.email <email> # set global email
git config --list # show Git configurationExample:
git config --global user.name "Dmytro Palahin"
git config --global user.email "dmytro.palahin@gmail.com"git init # initialize a Git repository in the project
git remote -v # show remote repositories
git remote add origin <repository-url> # add a remote repository
git push -u origin master # push changes to the remote repositorygit status # show staging area and changes to be committedgit log # view history of commitsgit add . # add all files from working directory to the staging area
git add -f environment.yml # add a specific file with force
git rm <file> # remove file from the staging area and working directorygit commit -m "<message>" # commit changes in the staging area with a messagegit checkout <commit hash> # checkout a specific commit
git checkout <branch name> # switch to an existing branch
git checkout -b <branch name> # create a new branch and switch to it
git checkout main # switch back to the main branchgit branch <branch name> # create a new branch
git branch # list all branches
git branch -a # list all branches, including remote ones
git branch -m <new name> # rename the current branch
git branch -d <branch> # delete a branch (can't delete the current branch)
git branch -vv # list all branches with additional informationgit merge <feature branch> # merge a feature branch into the current branch
git merge -m "<message>" <branch> # merge with a custom messagegit cat-file -t <commit hash> # show type of an object (commit, blob, etc.)
git cat-file -p <commit hash> # show content of the objectgit push # push changes from the local repository to the remote
git pull # apply changes from a remote repository into your current local branch
git clone <url> # clone a remote repository to the local machinegit remote add origin <url> # connect a remote repository
git remote # list remote repositories
git remote -v # show URLs for remote repositoriesgit push -u origin <branch> # push changes to the remote repository and track the branch
git push -u origin main # push changes to the main branchgit statusgit add <file> # add a specific file to the staging area
git rm <file> # remove a specific file from the repository
git restore <file> # undo changes in the working directory for a specific filegit commit -m "<message>"git push
git push --set-upstream origin <branch-name>git remote add origin <url>git remote -vgit branch -M maingit push -u origin maingit tag # list all tagsgit tag <tagname> # create a lightweight tag
git tag -a <tagname> -m "<message>" # create an annotated tag with a messagegit show <tagname> # show details of a specific taggit push origin <tagname> # push a specific tag to the remote repository
git push origin --tags # push all tags to the remote repositorygit tag -d <tagname> # delete a specific tag
git push origin --delete <tagname> # delete a tag from the remote repositorygit branch -m <old-branch-name> <new-branch-name>git push origin <new-branch-name>git push origin --delete <old-branch-name>git push --set-upstream origin <new-branch-name>git tag <new-tag-name> <old-tag-name> # create a new tag with the old tag's commit
git tag -d <old-tag-name> # delete the old tag locallygit push origin <new-tag-name>git push origin --delete <old-tag-name>