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

Every developer uses GIT every day and this is a pratical 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

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

git status

To reset local diffs:

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

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 into your project:

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

To retrieve a list of all tags:

git tag -l

--

--

--

I’m a software engineer based in Milan. Always looking to discover new development methods and technologies, I am an open source enthusiast and supporter.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Writing a Kubernetes CLI in Go

Combining Go and Kubernetes client APIs makes it easy to develop a custom CLI

Code Challenge: benchmarking the solution

The Art of Good Code Review

Truth n Dare Game with Coding in Python

An Interview with Priyanka Dobhal (a Tableau datafam community star)

5 things you should do if you’re learning to code

Build Engineering: Tools can Address a Myriad of Daily Challenges

vball.io — First results

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Pollastri

Andrea Pollastri

I’m a software engineer based in Milan. Always looking to discover new development methods and technologies, I am an open source enthusiast and supporter.

More from Medium

4 Tips To Make Production Debugging Easier

Colorful 404 error message with upside down smiley as the 0.

What is Multithreading? Pros and Cons.

Go — If/Else, Switch, and For loop

Git — errors