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

Introduction to HTML & CSS

Rewrite All Apache URLs to redirect to specific page

Blue Yonder Clear Report Cache

Teach Yodel how to pronounce words correctly with SSML

How to Use Markdown and Mkdocs to Write and Organize Technical Notes

Flutter Vs React Native: Choose Your Framework

Logo

How to Write Unit Tests in Python?

Find Sub-Array With The Given Sum

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

Fundamentals of Software Development: Essential Technologies

Frequently seen Bugs and their ‘Species’

Breaking down: Object Oriented Programming.

Synchronous vs. Asynchronous API Calls