Hey everyone! This will be a short and sweet blog on git commands. Let's git started (that was cringy for me too but I couldn't resist!).
Git init
This might be the simplest command. It creates a new repo and all you have to do is type this:
git init [repository name]
Git clone
This will to create a copy or "clone" of an existing repo. Just type:
git clone [url to the repo]
A handy shortcut that can be created is gcl, if you're into saving keystrokes check I'd suggest using it.
Git diff
Git diff shows the differences in files that have not yet been staged. To see them, all you have to type is "git diff".
Git diff --staged
This will show you the differences in the files that have been staged.
Git diff [branch1] [branch2]
Shows the differences between the specified branches.
Git reset
This will unstage a file but keep the contents the same.
git reset [file name]
Git reset [commit]
This command undoes all commits after the specified commit but changes are only saved locally.
Git reset -hard [commit]
Returns content back to the specified commit.
Git rm
Will delete the file from your working directory and stages it.
git rm [file]
Git remote
This command will connect your local repo to the remote server:
git remote add [variable name] [remote server link]
Example:
git remote add origin https://github.com/youracccount/repo.git
That's it for this time. Let me know what git commands you use often or think are important to know in the comments!!!
Resources: