git config --global user.name "name"
- setup users name in global config
git config --global user.email <email>
- setup users email in global config
git init
- initialization git in project
git status
- status local files
git log
- show log of all commits
-
git log --oneline
- short log -
git log --graph --oneline
- short log with drawled graph
git diff <(commit-id/branch)-from> <(commit-id/branch)-to>
- show log difference in commits
git diff --staged
- show log difference in commits
git branch <branch-name>
- create branch
-
git branch -v
- info about last commit -
git branch -M <branch-name>
- rename current branch -
git branch -d <branch-name>
- deletes this branch
git checkout <branch-name/commit-id>
- change current (HEAD) branch or change current commit
git checkout -b <branch-name>
- create and change current (HEAD) branch
git add <file1> <file2>
- add files for git indexing
git commit
- add commit
-
git commit -m "message"
- add commit changes with message -
git commit -am "message"
- add commit all last changes with message -
git commit --amend -m "new message"
- rename last changes commit -
git commit --amend --no-edit
- expand last commit with new files -
git commit --amend -c <commit-id>
- rename commit by id
git remote add origin <url>
- connect to first time created repo
-
git remote add pb <url>
- connect to already exist repo -
git remote -v
- log connected remotes
git stash
- archive last changes, which not committed (unfinished changes)
git stash pop
- get archive changes
git reset <commit-id>
- return to commit-id
git reset --hard
- return to one commit back
git restore <file>
- restore non staged file
git restore --staged <file>
- restore staged file
git revert <commit-id>
- reverts that commit with a new commit
git push
- upload last changes
git push -u origin <branch-name>
- upload branch
git pull
- download last changes
git pull --rebase origin <branch>
- pull with with rebase option (if have conflicts with origin branch)
git merge <branch>
- merge in current brunch
git merge --no-edit <branch>
- merge without message edit
git rebase <branch>
- rebase (overlay) commits from one branch to current or other
-
git rebase --abort
- cancel rebase -
git rebase --continue
- fix conflicts
-
git init
-
git add .
-
git commit -m "Init"
-
git branch -M main
-
git remote add origin <url>
-
git push -u origin main
-
git clone <url>
-
cd <cloned-repo-folder>
-
git remote add pb <url>
Remove untrack files
-
git rm -r --cached
-
git add .
-
git commit -m "Untrack files in .gitignore"
origin
- remote branch
-f
or --force
- force action
--staged
- staged (prepared with add
command) files
~
- parent / home
@
- HEAD - last commit
*
or .
- all; *
may not find files whose names begin with .
(like .env
)