Hi, fellow coders đ
This is a review post of our new Git Commands With Examples eBook which is a work in progress.
The good news is that you don’t need to be a sitting duck waiting for the eBook release.
You can get started with Git right now by using our quick guide.
Don’t already have our Git Commands Quick Guide? What are you waiting for, get it this instance!
The Git Commands Quick Guide is a truncated version of the soon-to-drop Git Commands With Examples eBook (weâre clearly very creative) and it’s absolutely free for all our lovely subscribers.
Yes, FREE đ„
It wasnât an easy task making a free guide – the thought still makes DM hyperventilate – but I insisted on a Git commands cheat sheet that was more than just a list of Git commands.
Okay, pauseâŠwhat đł
Whatâs a Git commands sheet thatâs more than just a list of Git commands?
The Git Commands Quick Guide goes over the most used Git commands.
You know, those of how to do things with Git like add, commit, and push code on a GitHub repo.
But weâre not simply listing the Git commands in a cheat sheet version, like Atlassian’s awesome Git cheat sheet (highly recommend you reference), because knowing what they are is only going to take you so far.
Instead, the Git Commands Quick Guide shows you how to use the most common Git commands with example steps to start doing things at this very moment.
Nice, huh đ
In the guide, we list the steps of Git commands to
- . . .download a repo to your local
- . . .start locally and push remotely
- . . .merge branches and push to the remote origin
- . . .add and commit changes
What’s in the Git Commands With Examples eBook?
For those whoâd like juicer bits and in-depth explanations of specific steps – including tips, hints, and notes – go for the Git Commands With Examples eBook.
The content of the eBook is literally what I refer to all the time when developing and working on projects.
Git Commands With Examples eBook is perfect for anyone starting with Git because itâll tell you and show you how to do things while speaking a little about the why behind it. You can use it as a reference when you get stuck or just need additional context.
Most of us donât need to become Git experts, we only need to work with the darn thing.
Iâm committed (catch the pun đ) to helping us do just that.
TIP
You run Git commands in your machine’s Terminal. Get started with the command line by reading How To Open And Run Commands In The Terminal (Beginner Friendly).
Now, let’s move onto a little glimpse of what to expect from the Git Commands With Examples eBook đ
Basic Git commands
git clone
Brings the repo hosted on GitHub into your local folder.
git add
Tracks files and changes (otherwise known as âstagingâ files).
git commit
Saves files usually with a message that notates what changes were made to the file(s).
git push
Uploads files to a remote repo.
git pull
Downloads changes from a remote repo to your local.
Hint đ
To check whether youâve installed Git use
git --version
Git Command to Download to Local
git clone [Repo URL]
Downloads a copy of the specified repo in a folder on your computer to work on the files.
Where to find the repo URL
Head over to your GitHub repo and click the Code dropdown where you’ll find the repo URL for cloning that specific repo.
How to see cloned repo files
Get a list of all files in a directory by doing two things:
cd [directory]
â move into a specific directoryls
â list all files and folders in the directory that arenât hidden
Tip
List everything, including hidden files and directories, using
ls --la
(the hidden .git folder holds all changes).
Once youâre done working on the files and want to update the repo follow with:
git status
It shows all modified files NOT committed. These are âuntrackedâ files that need to be added.
git add .
Tells Git to track all modified and untracked files.
To be selective on what is added, list the files separated by space.
git add [file 1] [file 2] [etc...]
Adding the files only means Git knows to track changes not save the changes.
Save the changes you made to the files using:
git commit -m "short descriptive title" -m "optional longer description of changes"
This is equivalent to filling out the following commit fields in the GitHub UI when you’re done editing a file.
Once changes are tracked and saved, youâre ready to push onto the repo.
git push origin master
origin â refers to the location of the remote repo
master â name of the branch youâre pushing the changes on the remote repo (this might be called something else for you)
If you get an error by the above command stating no origin is defined, then thereâs one more step you need to do.
Check existing remotes with git remote -v.
Add a new remote:
git remote add origin [repo-url]
Edit an existing one:
git remote set-url origin [repo-url]
Related: Click the link for more on when to add origin vs set-url origin.
For errors related to permissions, keep reading đ
How to connect your local to GitHub
Pushing your changes onto a remote repo wonât happen if you donât have permissions granting you access to the repo.
Youâll need to connect your local to GitHub by either generating an SSH key or an API token.
To be continued. . .
And that wraps the brief preview of the Git Commands With Examples eBook.
The eBook will be our most comprehensive guide to Git processes so we’re super excited to share it with you as soon as it’s complete.
Mhmmm the anticipation đ