DEV Community

Cover image for Understanding The Terminal & The Command Line
Charles Eugene
Charles Eugene

Posted on

Understanding The Terminal & The Command Line

Essential Git Commands for Software Development

Image description

If you're a seasoned developer or if its day one on the job understanding and mastering the Git is very essential! Git commands are literally your best friend whether it be for tracking code changes, working with others, or managing project workflows efficiently!

So what is Git and WHY should you use it?

Image description

Ahh Git! Git is a great control tool that helps developers manage project files and it keeps a history of all the changes you're making. It doesn't matter whether you're working by yourself or with a colleague. Git makes code management super smooth lets learn the tools needed to do so!

First steps

Navigating Directories

  • pwd: Will display the current directory you're in.

Image description

  • cd (directory name): Changes your working directory to the one you want.
  • cd ..: Also moves you up one directory level.

Image description

Files and Folders

  • ls: Will list all files and directories in that current location.

Image description

Creating Directories/Files

  • mkdir (directory name): This makes a new directory.

Image description

  • touch (file name): This will create a new empty file.

The Basic Core Commands

Image description

I'm a BIG believer in fundamentals and getting set up for success!

  • git init: To initialize a new Git Repository.

  • git config --global user.email IE: "youremail@example.com": To make your email for commits.

  • git config --list: This is to verify your Git settings.

Let's get you set up!

  • git add (file): This stage changes to a specific file.

  • git add .: Is the stage all changes in the directory.

  • git commit -m "Your Message": This commit is staged changes with a message.

  • git commit --amend: Use this if you need to change or modify the message or to include missing files.

Image description

Image description

Image description

Lets make changes!

  • git status: So you can see which files have changes.

Image description

  • git diff: This compares working directory changes.

  • git log: To view the commit history.

Image description

Branching and Merging

  • git branch: List all branches or if you need to create a new branch.

Image description

  • git checkout (branch name): This is to switch to a branch.

  • git checkout -b (branch name): This is to create and switch to a new branch in ONE step!

  • git merge (branch name): This merges another branch into your current one.

  • git branch -d (branch name): This will delete the entire branch.

Teamwork Remote Repositories

Image description

  • git remote add (person) (url): This will link your local repo to a remote repo [This is my current link to a colleague to see who you're connected to use git remote -v]

Image description

  • git push origin (branch name): This will upload the changes you made to a remote branch.

Image description

  • git pull: This will merge changes from a colleague or any remote branch you're connected to.

Image description

  • git fetch: You can get updates from a colleague or any remote branch you're connected to without merging.

Image description

Other Helpful Git Commands

CLONING :O
Image description

  • git clone: This will clone an existing repo.

Image description

  • rm (file name): This will delete a file.

Image description

  • rmdir (directory name): This will remove an empty directory.

  • ls -a: This will list all the files even the hidden ones!

Thats all Folks!

Image description

All the git commands listed above will help you navigate your role as a developer. You'll gain more control over your code and work flow whether its the simple commands or the more advanced ones! Use it to your benefit lets work smarter not harder!

Sources
https://cloudstudio.com.au/2021/06/26/git-command/

https://parade.com/947443/parade/best-friend-quotes/

https://www.cert-india.com/belbin-stack/leadership-and-teams

https://www.facebook.com/thebasics14/?locale=is_IS

https://education.github.com/git-cheat-sheet-education.pdf

https://www.atlassian.com/git

https://www.michiganstateuniversityonline.com/resources/leadership/how-to-build-a-culture-of-teamwork/

https://www.nytimes.com/2009/01/01/garden/01clones.html

https://www.archive360.com/blog/when-is-it-ok-to-delete-data

https://www.youtube.com/watch?v=3Qz1GMpOtUY

Top comments (0)