Welcome to our new repo, where we all learn to get good with git
😁
As you all know, using git
in a work environment is crucial for a Web Developers workflow. It is even more important when working with others.
I DO NOT claim to know everything there is to know about git
, as I have only ever used it in my own personal projects.
The purpose of this repo is for us/we/me/you to learn the basics of using git
, both for personal use as well as in a team environment.
- Watch this repo.
- Fork this repo.
- Clone your repo.
If you are an absolute beginner and know nothing about git
, then I encourage you to check out these GitHub docs.
These 9 commands are absolutely the BASIC ones you will most likely use for this project repo.
git init
;git clone
;git add
;git commit
;git status
;git branch
;git merge
;git pull
;git push
I have used these for years and type them a hundred times per day.
-
git init
The subcomand
init
is short for "initialize".When you type this command in a new folder, this "initializes" a
git
repository and begins tracking the files in that folder. It will create a hidden folder called.git
that contains the directory structure for your project version control.You can now continue working on your project, create, edit, delete, and move files around. As you make changes, you are encouraged to
add
andcommmit
regularly, so you can always track your progress and create "snapshots" of your code as your project grows.In this screenshot, before I run
git init
, I run the commandll
. In Linux that command says "List Files". Afterll
I rungit init
and you see the following when I runll
again, it shows a folder called.git
in the new-test-folder`. -
git clone
This will make a copy of a remote repo on your local machine. This will contain all the files and folder structure, the entire commit history and the branches.
You have several options when it comes to cloning a repo.
Option 1: Default method
This will clone this repo into a new folder that I chose to name "wtb-get-good-with-git".
When you
cd
into that folder, you will see all the project files and folders.git clone https://github.com/jjaimealeman/wtb-get-good-with-git.git
Option 2: Clone into your own folder root
Create your own folder and run the command there.
git clone https://github.com/jjaimealeman/wtb-get-good-with-git.git .
Option 3: Rename the folder
This will clone this repo into a new folder called "name-of-new-folder".
git clone https://github.com/jjaimealeman/wtb-get-good-with-git.git name-of-new-folder
-
git status
As you make your changes, and you create & delete files,
git
will keep track of everything.It will track new files that have not been added. It will track files that have been deleted. And of course it will track files that have been modified.
Here you see that I modified
readme.md
andsrc/index.html
as shown with a red capital "M" on the left.I also deleted
file-that-i-will-delete.txt
andsrc/images/screenshot-git-status.png
as shown with a red capital "D" on the left. -
git add
I start with a plain
.html
document skeleton and later plan on including some Google Fonts and a nice background image. I decide togit add src/index.html
before I work on the CSS.So I
git status
followed bygit add src/index.html
-
git commit
Before I begin working on the styles of the homepage, I decide to
git commit
my current progress for the homepage. I could run two separate commands like thisgit add src/index.html
and then dogit commit -m'my commit message'
But I sometimes like to put the two together, like this:
git add src/index.html && git commit -m'index.html added H1 and #container with paragraphs'
- 6.
git branch
- 7.
git merge
- 8.
git pull
- 9.
git push