{"id":21303126,"url":"https://github.com/bzon/gittutorial","last_synced_at":"2026-01-02T08:15:09.311Z","repository":{"id":141940530,"uuid":"102408509","full_name":"bzon/gitTutorial","owner":"bzon","description":null,"archived":false,"fork":false,"pushed_at":"2017-09-07T19:11:45.000Z","size":8209,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T08:28:40.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bzon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-04T22:42:12.000Z","updated_at":"2019-03-11T21:09:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"49ecc0e3-c4ff-420a-a899-4c23f0ad469b","html_url":"https://github.com/bzon/gitTutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzon%2FgitTutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzon%2FgitTutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzon%2FgitTutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzon%2FgitTutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bzon","download_url":"https://codeload.github.com/bzon/gitTutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243776709,"owners_count":20346353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T15:58:59.670Z","updated_at":"2026-01-02T08:15:09.282Z","avatar_url":"https://github.com/bzon.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Tutorial Overview\n\nThe purpose of this README is to guide a users with zero to minimal knowledge in Git SCM using a Unix Terminal (Git Bash for Windows users).  \n\nThe full Git SCM documentation can be found [here](https://git-scm.com/docs).  \n\n## Table of Contents\n- [Installation](#installation)\n\t* [Windows](#windows)\n\t* [Mac OSX](#mac-osx)\n- [Setting up Local Git Configuration](#setting-up-local-git-configuration)\n- [Creating a Local Git Repository](#creating-a-local-git-repository)\n- [Basic Git usage and commands](#basic-git-usage-and-commands)\n\t* [Adding files in a Git repository](#adding-files-in-a-git-repository)\n\t* [Tracking or Staging a file](#tracking-or-staging-a-file)\n\t* [Commit a Staged file](#commit-a-staged-file)\n\t* [Untracking or Unstaging a file](#untracking-or-unstaging-a-file)\n\t* [Interactive Challenge](#interactive-challenge)\n- [Git Branches](#git-branches)\n\t* [Create a feature branch](#create-a-feature-branch)\n\t* [Add a change in a feature branch](#add-a-change-in-a-feature-branch)\n\t* [Git Merge](#git-merge)\n- [Gitlab](#gitlab)\n\t* [Gitlab User Guide](#gitlab-user-guide)\n\n# Installation\n\n## Windows\n\nInstall Git \u0026 Git Bash  \n\nhttps://git-scm.com/download/win\n\nOnline installation and Git Basic guide for Windows user  \nhttps://www.youtube.com/watch?v=Y9XZQO1n_7c\n\nEnsure that the following configurations are followed:  \n\n![img](./img/git_win_setup_1.png)\n![img](./img/git_win_setup_2.png)\n![img](./img/git_win_setup_3.png)\n\n## Mac OSX   \n```bash\nbrew install git\n```\n\n# Setting up Local Git Configuration\n\n__Command line__: User \u0026 Email setup \n```bash\ngit config --global user.name \"John Bryan Sazon\"\ngit config --global user.email \"john.bryan.j.sazon@accenture.com\"\n```\n\n__Command line__: Storing Git credentials so you don't have to type password everytime\n```bash\ngit config --global credential.helper store\n```\n\n__Command line__: View Git configurations  \n```bash\ngit config --list\n```\n\n__Command line__: View Git configurations from the .gitconfig file  \n```bash\ncat ~/.gitconfig\n```\n__Command Output__:  \n```bash\n$ cat ~/.gitconfig \n[credential]\n\thelper = store\n[user]\n\tname = John Bryan Sazon\n\temail = john.bryan.j.sazon@accenture.com\n```\n\n# Creating a Local Git repository\n\n__Command line__: Create an empty directory \u0026\u0026 `cd` into it \n```bash\nmkdir -p Training/Git/my_repository\ncd Training/Git/my_repository\n```\n\n__Command line__: Initialize the empty `my_repository` directory as a Git repository  \n```bash\ngit init .\n```\n`git init` Command Standard Output:     \n```bash\nInitialized empty Git repository in /Users/bryanguestuser/Training/Git/my_repository/.git/\n```\n\n# Basic Git usage and commands\n\n**Current working directory**: `Training/Git/my_repository`\n\n## Creating a new file\n\n__Command line__: Create a file  \n```bash\ntouch readme.md\n```\n\n__Command line__: Using `git status` to view repository status \n```bash\ngit status\n```\n__Command Output__:\n```bash\nOn branch master\n\nInitial commit\n\nUntracked files:\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n\n\treadme.md\n```\nGit tells you that `readme.md` file is `untracked`  \n\n## Tracking or Staging a file\n\n__Command line__: Using `git add` to track a file  \n```bash\ngit add readme.md\n```\n\n__Command line__: Using `git status` to identify repository status\n```bash\ngit status\n```\n__Command Output__:\n```bash\nOn branch master\n\nInitial commit\n\nChanges to be committed:\n  (use \"git rm --cached \u003cfile\u003e...\" to unstage)\n\n\tnew file:   readme.md\n```\n\nThis is called `staging`. Git tells you that you tracked the `readme.md` file and it is ready for a `commit`.\n\n__BUT__ what if we change the content of the `readme.md` file because you are not ready to `commit` your change in the repository for this file?  \n\n### Modifying the file after git add\nBefore proceeding, try modifying the file as you would normally edit a text file. Once done, run a `git status`.  \n\n__Command line__: Using `git status` to view repository status \n```bash\ngit status\n```\n__Command Output__:\n```bash\nOn branch master\n\nInitial commit\n\nChanges to be committed:\n  (use \"git rm --cached \u003cfile\u003e...\" to unstage)\n\n\tnew file:   readme.md\n\nChanges not staged for commit:\n  (use \"git add \u003cfile\u003e...\" to update what will be committed)\n  (use \"git checkout -- \u003cfile\u003e...\" to discard changes in working directory)\n\n\tmodified:   readme.md\n```\nNow we see that the `readme.md` file is both tracked and untracked. \n\n__WHY?__ \n\nIt is because when we run the `git add` command to add a file, git __ONLY__ `stage` the file as it was at the time you executed the command. Remember, we only [executed git add once](#tracking-or-staging-a-file) after creating the file and before any modification, and the `git status` command above tells you that there is an `unstaged` change in the file because we [modified](#modifying-the-file-after-git-add) it just after running `git add readme.md`.  \n\nRun the `git add` command once again, to include the latest revision of the `readme.md` file.  \n\n__Command line__: Using `git add` to track a file  \n```bash\ngit add readme.md\n```\n__Command Output__:\n```bash\nOn branch master\n\nInitial commit\n\nChanges to be committed:\n  (use \"git rm --cached \u003cfile\u003e...\" to unstage)\n\n\tnew file:   readme.md\n```\n\n## Commit a Staged file\n\n__NOTE__: If you are new to `vim` please see the [vim guide](./VIM.md)\n\n`git commit` lets you save your local revisions into your local git repository.  \n\n__Command line__: Using `git commit`\n```bash\ngit commit\n```\nYou will end up in the `vim` screen where you can enter your `commit message` and view the changes that will be committed.  \n\n![gif](./img/vim_git_commit.gif)\n\nUse `git log` to view the commit history of the current repository. Use `git log --oneline --decorate` to display a decorated output.  \n\n## Untracking or unstaging a file\n\nThere will be cases that you may have already `staged` a new revision in the repository by running `git add`,  \n\nLet's first create a file and stage it.  \n\n__Command line__: Create a file \n```bash\ntouch unwanted_file.txt\n```\n\n__Command line__: Use `git add` to track a file  \n```bash\ngit add unwanted_file.txt\n```\n__Command Output__:\n```bash\nOn branch master\nChanges to be committed:\n  (use \"git reset HEAD \u003cfile\u003e...\" to unstage)\n\n\tnew file:   unwanted_file.txt\n```\n\n__BUT__ you suddenly want to revert or `unstaged` it for some reason to prevent having that revision to be included in your `git commit`.  \n\n__Command line__: Using `git rm` to untrack a file \n```bash\ngit rm --cached unwanted_file.txt\n```\n__Command line__: Using `git status` to view repository status \n```bash\ngit status\n```\n__Command Output__:\n```bash\nOn branch master\nUntracked files:\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n\n\tunwanted_file.txt\n```\n\nYou can run `rm unwanted_file.txt` to delete the unwanted file.  \n\n## Interactive Challenge\n\nTry to complete the following! https://try.github.io/  \n\n# Git Branches\n\nA branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master . As you start making commits, you're given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.  \n\nhttps://git-scm.com/book/id/v2/Git-Branching-Branches-in-a-Nutshell\n\n__Command line__: Using `git branch` to view the branches in the local repository\n```bash\ngit branch\n```\n__Command Output__:  \n```\n* master\n```\n\n## Create a feature branch\n\n__Command line__: Using `git checkout` to create a branch from the `master` branch  \n```bash\ngit checkout -b feature-branch\n```\n__Command line__: Using `git branch` to view the branches in the local repository\n```bash\ngit branch\n```\n```bash\n* feature-branch\n  master\n```\n\n__Command line__: Using `git checkout` to go to a different branch  \n```bash\ngit checkout master # goes to master branch\ngit checkout feature-branch # goes to feature-branch\ngit checkout - # goes to the previous branch\n```\n\n## Add a change in a feature branch\n\n__Command line__: Ensure you are in the `feature-branch`  \n```bash\ngit checkout feature-branch\n```\n\n__Command line__: Create a file called `my_new_feature.txt`  \n```bash\ntouch my_new_feature.txt\n```\n\n__Command line__: Using `git add` to track a file  \n```bash\ngit add my_new_feature.txt\n```\n\n__Command line__: Using `git status` to identify repository status\n```bash\ngit status\n```\n\n__Command line__: Using `git commit` to commit a file using vim. Reference: [vim guide](./VIM.md)  \n```bash\ngit commit\n```\n\n## Git Merge\n\nMerging a source branch to a target branch.  \n\n__Command line__: Using `git merge` to merge `feature-branch` branch into the `master` branch\n\n```bash\ngit checkout master\ngit merge feature-branch\n```\n\nUse `git log` and you should see that the commit from `feature-branch` is now integrated to the master branch.  \n```bash\ngit log\n```\n\n# Gitlab\n\n__Why Gitlab?__  \n\nGitlab is basically like Bitbucket and Github but it is the only one that offers an opensource version of their software, the `Community Edition`. You can install in your own computer or host it within your project's infrastructure for __FREE__ unlike Bitbucket and Github.  \n\nFrom a DevOps project requirement perspective it gives you a nice web user interface, a code review feature and an integration with Jenkins. More Gitlab features can be found [here](https://about.gitlab.com/features/).  \n\n__Disadvantage?__  \n\nIt's a heavy weight Git server and there are too many features that aren't necessarily needed.  \n\n__Opensource Alternatives?__\n\n[Gerrit](https://www.gerritcodereview.com) - \nThe best Git code review tool ever made IMO and the branching model of making use of a virtual branch is awesome. However, extending it with more features requires you to compile the plugins and install it by following some documentations. The user interface is not so intuitive and it takes a while to get a hang of it.  \n\nAnother famous opensource Git server is [Gogs](https://gogs.io). It is still in its pre-release 1 phase and it doesn't support Code Reviews yet. \n\n## Gitlab User Guide\n\n* [Registration](https://gitlab.com/users/sign_in)\n* [Gitlab Basics](https://docs.gitlab.com/ce/gitlab-basics/README.html)\n\t* [Create your SSH Keys](https://docs.gitlab.com/ce/gitlab-basics/create-your-ssh-keys.html)\n\t* [Create a group](https://docs.gitlab.com/ce/user/group/index.html#create-a-new-group)\n\t* [Create a project](https://docs.gitlab.com/ce/gitlab-basics/create-project.html)\n\t* [Adding a file](https://docs.gitlab.com/ce/user/project/repository/web_editor.html#create-a-file)\n\t* [Creating a branch](https://docs.gitlab.com/ce/user/project/repository/web_editor.html#create-a-new-branch)\n\t* [Forking a project](https://docs.gitlab.com/ce/gitlab-basics/fork-project.html)\n\t* [Creating a Merge Request](https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzon%2Fgittutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbzon%2Fgittutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzon%2Fgittutorial/lists"}