getting git ready

Karthik Ram
2 min readOct 3, 2023

--

Photo by Roman Synkevych on Unsplash

Learning git offers a wide rage of benefits. Apart from the the fact that it allows you to version control software, the main benefit of git is COLLABORATION.

I truly understood its importance after working in a agile software development team, so I highly recommend learning in a collaborative project setting.

Although there are a lot of git commands to learn, I’m listing down the most frequently used commands. These will get you up and running as soon as possible.

Lets go!

  1. git init: Initializes a new git repository in a directory. Use this if you are starting off a new project and you want to track it in your local repository.
  2. git clone: This commands creates a copy of a remote repository on your machine.
  3. git add: This command is used to stage changes into the current branch. You can either specify individual files or folders or you can stage all chages by using $ git add .
  4. git commit: this command records the staged changes with a message.
    $ git commit -m “Work in Progress”
  5. git status: This gives you a snap shot of your current directory. It show files that are staged vs not staged.
  6. git log: Displays all commits made in the past chronologically. This information can be used to jump to previous versions of the current branch
  7. git branch: lists all branches in the repository. This command can also be used to create or delete branches
  8. git checkout: lets you switch branches or commit (from commit history that can be read from git log)
  9. git pull: Gets all changes from a remote repository and merges the code with the current branch you are in.
  10. git push: Updates the remote repository with the commits made in the local repository
  11. git merge: Combines changes from one branch to another. For instance if you want to merge changes from a feature branch to a production branch, you would switch to the production branch and then $ git merge feature-branch
  12. git diff: Shows difference in code between commits
  13. git reset: This is used to unstage a file. There are two types of resets
    $ git reset — soft <commit_hash> preserves changes from the current commit and switches to a specified commit hash
    $ git reset — hard <commit_hash> discards changes from the current commit and switches to a specified commit hash
  14. git stash: git stash as the name suggests, store the changes on a branch into a cache, allowing you to do other operations like switching branches or pulling from a remote repository
    $ git stash save “message”: stashes changes with a message
    $ git stash pop: applies the most resent changes in the stash list

--

--