GIT F.U.C. (Frequently Used Commands)

Andrea Pollastri
2 min readJan 30, 2022

Every developer uses GIT every day and this is a practical list of F.U.C.
(Frequently Used Commands).

When we work on a project based on a standard “Git flow” situation, we have to create our feature branch using:

git checkout -b <feat-xyz>

This command will check out our code on a branch “feat-XYZ” (and create it if it doesn’t exist) starting from the current branch.

To discover what is the current and the available branches:

git branch # or git branch -b (to explore remote branches)

To check the status of our branch (uncommitted files and their diffs):

git status

To add untracked files to your Git:

git add <file>
#or git add --all

To restore uncommitted changes

git restore <file>

To stash/reset local diffs:

git stash
#or git reset --hard origin/<remote-branch>
#or git reset --hard && git clean -df

To stash our files and prepare them for a commit:

git add <file name> # or git add --all (to add all files)

To create a commit:

git commit -a -m "<some messagge>"

To share our code, we have to push on remote our commits:

git push # or git push -u origin <feat-xyz>

To receive remote updates:

git pull # or git fetch && git pull

To rename the last commit:

git commit --amend 
git push origin --force-with-lease

To merge our branch into another (final branch):

# Rebase a feat-branch on the final branch
git checkout <final-branch>
git pull
git checkout <feat-xyz>
# use git rebase <final-branch>
# or better (-i squashs all commits… no -i doesn’t)
git rebase -i <final-branch>
# Leave just one commit changing “pick” with “f” letter
git push origin --force-with-lease

To add a TAG to your project:

git tag -a v1.4 -m "my version 1.4"

To retrieve a list of all tags:

git tag -l

--

--