This repository is used to practice git commands and github workflows for the Git Good with Adrian workshop.
- Install git on your machine
- Configure git with your name and email
git config --global user.name "<your_name>"git config --global user.email "<your_email>"- Do not use your student email!
- Create a github account (again do not use your student email)
- Fork this repository to your github account
- On local machine, create a directory
C:\users\<yourname>\dev\ - Navigate to the directory
C:\users\<yourname>\dev\ - Clone this repository to your local machine in current directory
- Pull latest changes from upstream remote repository
- If there is no upstream remote repository, add it with the following command
git remote add origin https://github.com/AdrianCapacite/git-good-wth-adrian.git
- Pull latest changes from upstream remote repository
git pull origin master
- If there is no upstream remote repository, add it with the following command
- Create a new branch with your name
- Edit the git_masters.json file
- Follow the format of my entry in students
- Name
- Your perferred language
- Follow the format of my entry in students
- Add the file to the staging area
- Commit the file to the local repository
- Merge changes into the main branch
- Push changes to the remote repository
Sometimes merge conflics happen and you have to resolve them.
-
Merge the branch
joeinto the main branch- Git will tell you that there is a merge conflict
-
Open the file with the merge conflict, You will see the following
-
<<<<<<< HEAD Your changes ======= Joe's changes >>>>>>> joe
-
The between
<<<<<<< HEADand=======are the changes in the current (main) branch -
The between
=======and>>>>>>> joeare the changes in the joe branch
-
-
Delete joe's changes and keep your changes by deleting between
=======and>>>>>>> joe -
Then delete the lines
<<<<<<< HEAD,=======and>>>>>>> joe -
Commit the changes
-
Push changes to the remote repository
- Log into github
- Navigate to the upstream remote repository
- Create a pull request
- Wait for approval
| Command | Syntax | Description |
|---|---|---|
git clone |
git clone <repository_url> |
Makes a copy of a remote repository onto your local machine. |
git pull |
git pull <remote> <branch> |
Fetch & merges changes from the remote repository to your local repository. |
git push |
git push <remote> <branch> |
Copies & merges changes from your local repository to the remote repository. |
git add |
git add <file_name> |
Adds changes made in the current working directory to the Index (Staging). |
git commit |
git commit -m "<commit_message>"\ |
|
git commit -a |
Commits changes to the local repository.\ | |
-a attribute specifies to commit changes straight from working directory to repository. Ignnores untracked files. |
| Command | Syntax | Description |
|---|---|---|
git branch |
git branch |
Lists all branches in the local repository. |
git branch |
git branch <branch_name> |
Creates a new branch in the local repository. |
git checkout |
git checkout <branch_name> |
Shows the specified branch or commit in the working directory. |
git branch -d |
git branch -d <branch_name> |
Deletes the specified branch in the local repository. |
git merge |
git merge <branch_name> |
Merges the specified branch into the current branch. |
git rebase |
git rebase <branch_name> |
Replays commits from the current branch on top of the specified branch. |
| Command | Syntax | Description |
|---|---|---|
git status |
git status |
Shows the status of the working directory and staging area. |
git log |
git log |
Shows the commit history for the current branch. |
git diff |
git diff |
Shows the difference between the working directory and the staging area. |
git revert |
git revert <commit_hash> |
Undos a specific commit with a new commit. |
git reset |
git reset <commit_hash>\ |
|
[--soft] [--mixed] [--hard] |
Moves head to the specified commit.\ | |
--soft keeps changes after specified commit in index\ |
||
--mixed keeps changes after specified commit only in working directory\ |
||
--hard discards all changes after specified commit |
- Git Crash course: brandon1024/GITCRASHCOURSE.MD
- Git Cheat Sheet: https://training.github.com/downloads/github-git-cheat-sheet/
- Visual Git Cheat Sheet: https://ndpsoftware.com/git-cheatsheet.html
- GitKraken/GitLens - Visual Git Client