Categories
General

Git Basic Commands

Basic Git commands that you can use daily.

In this blog post you can find Git Commands that I use very often:

  • Initialise empty git repository to start everything,
    • git init
  • Add all files recursively to git repository as tracked files,
    • git add -A
  • Capture git repository image; On Git world it is called as a commit.
    • git commit -am "..."
  • View all commits that saved before in repository,
    • git log
  • View all files that were tracked and not tracked. So you can see which files will be included in the next commit.
    • git status
  • Search for specific word or line inside all files in the repository. (Same like grep -rwn -e "..." . )
    • git grep "..."
  • Goes back older repo image which specified in commit number.
    • git reset --hard <commit no>
  • After <git reset –hard> command, shows which files can be deletable.
    • git clean -ndx
  • After <git reset –hard> command, delete all files which can be deletable.
    • git clean -fdx
  • Generates a new branch.
    • git checkout -b <branch name>
  • Delete branch.
    • git branch -d <branch name>
  • Use this to switch between branches but commit must be taken in the current branch before using this command.
    • git checkout <branch name>
  • İki commit arasında değişen dosyaları ve değişiklikleri gösteren  bir patch dosyası oluşturur,
    • git diff <1.Commit> <2.Commit> > <file name>

Thanks for reading.

By Emre Anıl TERZİOĞLU

Embedded Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *