Git is a free and open source distributed version control systemhttps://git-scm.com/
Let's create a git repository
# git init
From here we can add files to our repo
# git add file
And we can check the status of our repo
# git status
Tracked files are those in your repo, while untracked files have not yet been added to the repo.
Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add
..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: index.html Untracked files: (use "git add ..." to include in what will be committed) images/cat-delete.png images/hoax.png images/moscow.JPG images/pexels-photo-428430.jpeg no changes added to commit (use "git add" and/or "git commit -a")
We need to add files to the repo so they can be tracked.
# git add index.html # git add .
Don't be afraid to commit....to the local repo
# git commit index.html # git commit -a # git commit -a -m "Message Goes Here"
We can take a look at that log
# git log commit 35e4b1b535c148a703911ca7f07e25f7eaf57356 (HEAD -> master) Author: Alex
Date: Fri Jun 8 13:21:01 2018 -0500 Adding the images commit c3beb7ed5ddd6463e98e8988c030ad7832165220 (origin/master) Author: Alex Date: Wed May 23 16:27:50 2018 -0500 Updated files
# git log --oneline 35e4b1b (HEAD -> master) Adding the images c3beb7e (origin/master) Updated files b62f3b9 Added the images 6dca960 Initial Commit a2e69a4 Merge pull request #2097 from bnjmnt4n/docs/readme
One of the big benefits of of version control is being able to roll back to a previous version of a file.
With the diff and checkout commands we see what is different and revert back.
# git diff < FILE > # git diff b62f3b9 6dca960 --oneline < FILE >
# git checkout file
GitHub, GitLab, BitBucket and all the like are web based repository hosting platforms. These platforms offer up a way to share, collaborate and contribute code.
# git clone firstname.lastname@example.org/gentle-git-intro.git
When we work with a hosted repo we have a remote URL we push to and fetch from.
$ git remote -v origin git@some-url/repo.git (fetch) origin git@some-url/repo.git (push)
Pushing is syncing your changes and commit logs with a remotely hosted repository.
# git push Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 830 bytes | 830.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) To gitlab.unsupported.io:mralexjuarez/gentle-git-intro.git b8516bd..85c3079 master -> master
We can use the fetch or the pull command to bring down content from the remote repository
# git fetch
# git pull
A fetch will pull down remote references and commits but not update the local repository.
A pull will both fetch the remote references and merge the new content in the current branch.
Once we want to sync our changes with the remote repository.
Setting Up GitLab for Fun and Profit @ 1:00PM
This should be a good start. There is still A LOT of git to explore but I'll leave that up to the reader.
Or we can talk about whiskey