Clone a remote repository on your local machine ``` git clone ``` List all local branches ``` git branch ``` List all local and remote branches ``` git branch -a ``` List all tags ``` git tag -l ``` Checkout a specific branch, tag, revision, file or a directory ``` git checkout git checkout tags/ git checkout git checkout origin/master -- git checkout origin/master -- ``` Stashing changes ``` git stash list git stash git stash pop git stash drop ``` Ignore changes in a file that is currently being tracked ``` git update-index --assume-unchanged ``` Start tracking changes in a file that has been previously ignored ``` git update-index --no-assume-unchanged ``` Revert changes made in a previous commit ``` git revert ``` Show change history of a file ``` gitk ``` Resolve merge conflicts ``` git mergetool ``` If already in conflict state, and want to accept all of theirs ``` git checkout --theirs . git add . ``` If already in conflict state, and want to accept all of ours ``` git checkout --ours . git add . ``` Undo the act of committing, leaving everything else intact ``` git reset --soft HEAD^ ``` Undo the act of committing and everything you'd staged, but leave the work tree (your files intact) ``` git reset HEAD^ ``` Completely undo it, throwing away all uncommitted changes, resetting everything to the previous commit ``` git reset --hard HEAD^ ``` Reset local branch to previous commit ``` git reset --hard e3f1e37 ``` Hard reset remote branch to previous commit ``` git reset --hard e3f1e37 git push --force origin develop ``` Hard reset to clean untracked files and directories ``` git clean -f -d ``` Files changed in this branch ``` git diff master.. --name-only ``` Cherry-pick commits from one branch into another ``` for commit in $(git log --reverse --pretty=%H --since="2021-05-27T17:19:00" --until="2021-05-30T12:03:00" --all); do git cherry-pick $commit done ``` Get changes from GitHub template On the other repositories you have to add this template repository as a remote. git remote add template https://github.com/bit-oasis/template-service.git Then run git fetch to update the changes git fetch --all Then is possible to merge another branch from the new remote to your current one. git merge template/main --allow-unrelated-histories Rebase your branch to master branch git rebase master git push --force origin your_branch_name If you have a branch A from master and then another branch B from A and want to connect B to master git checkout B git rebase A --onto master git push --force origin B