-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial review to help clarity #20
Open
dtwwwc1e
wants to merge
5
commits into
HealthBioscienceIDEAS:main
Choose a base branch
from
dtwwwc1e:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+45
−31
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd14f57
Initial review to help clarity
dtwwwc1e 90a6935
Initial review, making changes to help clarity
dtwwwc1e 4c4db59
Minor correction
dtwwwc1e 7a70ac0
Answer question 1_Git_and_GitHub.md
mary-tziraki d3caa85
Answered David questions Update 3_First_Git_Commands.md
mary-tziraki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
# First Git Commands | ||
You should have already completed the setup instructions for this workshop and have Git installed. Launch a command line environment (in Windows launch “Git Bash” from the Start Menu, on Linux or Mac start a new Terminal). We will use this command line interface throughout these materials, we prefer this for educational reasons because the command line is a common environment for all the operating systems. | ||
**[DW]** The episode before this is "Git and Github" which is about concept. Here, this episode moves to hands-on use of Git. If we provide a link to the setup instruction, it will help with the transition from concept to practical. [/DW] | ||
**[MT]** I would move it to the 1_Git-and_GitHub and name it 1_Git-and_GitHub_firts_commands. [/MT] | ||
|
||
You must provide some extra information before it is ready to interact with Git. | ||
The information is related to the person who uses Git and it gives the identity of the user in any project which you might work on your computer. In collaborative projects this is used to distinguish who has made what changes. You only need to perform the above commands once for each new computer Git is installed on. | ||
You should have already completed the setup instructions for this workshop and have it installed. You might have launched a command line environment (in Windows launch “Git Bash” from the Start Menu, on Linux or Mac start a new Terminal). We will use this command line interface throughout these materials, we prefer this for educational reasons because the command line is a common environment for all the operating systems. | ||
|
||
You must provide some extra information before it is ready to interact with git. | ||
The information is related to the person who uses git and it gives the identity of the user in any project which you might work on your computer. In collaborative projects this is used to distinguish who has made what changes. You only need to perform the above commands once for each new computer Git is installed on. | ||
|
||
**[DW]** A little more hand holding might be useful, i.e. show a picture of Bash, and then explain the git config commands. [/DW] | ||
**[MT]** OK I'll creare screen shots for eveything. I have created a presentation and it has short videos in it. That's why I havent got the images here. | ||
|
||
```bash | ||
git config --global user.name "FIRST_NAME LAST_NAME" # Use the name that you wish to be identified | ||
|
@@ -11,12 +17,11 @@ The information is related to the person who uses Git and it gives the identity | |
``` | ||
|
||
## Creating a Repository | ||
Now the Git is ready and we will use it in a new project. | ||
Now Git is ready and we will use it in a new project. | ||
In Git terminology a project is called a repository (frequently shortened to repo). | ||
Let's start a project withing your directories. Lets create a directory called cooking where we will store some folders and recipes. | ||
\Users\mary\cooking | ||
Let's start a project within your directories. Let's create a directory called 'cooking' where we will store some folders and recipes. We want 'cooking' to be immediately under our home directory, e.g. \Users\mary\cooking | ||
|
||
Within cooking we create (with mkdir) other directories, recipes, tools, videos. We go to the directory recipes and we create pizza.md and cake.md files. There we write and instructions | ||
Within 'cooking' we create (with `mkdir`) other directories: 'recipes', 'tools', 'videos'. We go to the directory recipes and we create files 'pizza.md' and 'cake.md' files. | ||
```bash | ||
pwd | ||
``` | ||
|
@@ -49,6 +54,9 @@ Create pizza.md and cake.md | |
touch pizza.md cake.md | ||
ls | ||
``` | ||
|
||
**[DW]** An output needing for the 'ls' command just above here. [/DW] | ||
|
||
## Create a Git repository | ||
To start using Git with our recipes we need to create a repository for it. Make sure the current working directory for your terminal is recipes and run: **git init** | ||
|
||
|
@@ -71,29 +79,31 @@ Output | |
. .. .git cake.md pizza.md | ||
``` | ||
We can see the hidden directory .git in the recipes directory, this signifies that it is a Git directory. | ||
In general we can create various Git repositories within your projects, whatever happens in those folders, whatever git commands you run , whatever history is stored there are completely separated and not connected. | ||
In general we can create various Git repositories within your projects. Whatever happens in those folders, whatever git commands you run, whatever history is stored, they are completely separated and not connected. | ||
**BEWARE** when you initialise a Git repository inside a folder all the nested folders within it are automatically in the Git repository (there is no need to initialise Git within the directory again). | ||
|
||
It is a common mistake to create Git directories in some or all the subdirectories, this complicates the process and end in error messages. | ||
|
||
The folder tree of this project should look like the picture. Only the directory recipes is a Git repo. (the Git sign is added for visualizing that we have initiated a Git repo, you will not see it at your computer) | ||
|
||
**[DW]** Picture belog does not show up [/DW] | ||
|
||
![Directories_tree](./fig/repo_directories_tree.png) | ||
|
||
## Master and main branches (You DON'T need to TYPE the COMMANDS in this section if you've done them in the set-up) | ||
Traditionally, the default branch name in Git whenever you init a repository was master. However, the sensitivity of the online community has shifted lately and GitHub, use now main as the default name instead. | ||
Traditionally, the default branch name in Git whenever you init a repository was master. However, the sensitivity of the online community has shifted lately and GitHub now use 'main' as the default name instead. | ||
You can read the reason in this [link](https://www.theserverside.com/feature/). | ||
|
||
**If you have done this step in the set up page and you don't need to repeat it here** | ||
|
||
If you are using git version 2.28 or higher (you can find the version you are using with git --version) you can change the default branch name for all new repositories with: | ||
If you are using Git version 2.28 or higher (you can find the version you are using with git --version) you can change the default branch name to 'main' for all new repositories with: | ||
|
||
```bash | ||
git config --global init.defaultBranch main | ||
``` | ||
With this command the word "master" in the Git code, it is being replaced by the word "master" as the GitHub uses it. So there is an alignment for the main branch between Git and GitHub | ||
With this command the word "master" in the Git code is replaced by the word "main" and GitHub will use it from then on. So there is an alignment for the main branch between Git and GitHub. | ||
|
||
For existing repositories or if your git version is lower than 2.28, you can create the master branch normally and then re-name it with: | ||
For existing repositories or if your Git version is lower than 2.28, you can create the master branch normally and then re-name it with: | ||
|
||
```bash | ||
git branch -m master main | ||
|
@@ -128,11 +138,11 @@ This is a very useful command that we will use a lot. It should be your first po | |
Don’t worry about all the output for now, the important bit is that the 2 directories and their files we already have are untracked in the repository (directory). | ||
|
||
We want to add the files to the list of files tracked by Git. Git does not track any files automatically and you need make a conscious decision to add a file. | ||
At the next session 4_Git_Commit_Commands you will be instructed how to make changes over time and save them in tracked versions indicated by messages. | ||
At the next session **[DW]** check session name [/DW/] 4_Git_Commit_Commands you will be instructed how to make changes over time and save them in tracked versions indicated by messages. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this a link please? |
||
|
||
## Common mistake of creating multiple Git repos | ||
|
||
As discussed above, creating Git repositories within and Git repository will cause confusion!! | ||
As discussed above, creating Git repositories within an existing Git repository will cause confusion!! | ||
|
||
![Warning](./fig/Warning_repo.png) | ||
|
||
|
@@ -158,10 +168,10 @@ Initialized empty Git repository in /Users/mary/cooking/recipes/food/.git/ | |
(base) mary food % ls -a | ||
. .. .git curry.md pizza.md | ||
``` | ||
Always check with **ls -a** and you observe that amongst the files in the food directory there is a .git hidden directory that you don't want to be there as it will confuse Git. | ||
You need to remove it using the ** rm -r** command for removing directories. | ||
Always check with **ls -a** and you observe that amongst the files in the food directory there is a .git hidden directory that you don't want it to be there as it will confuse Git. | ||
You need to remove it using the **rm -r** command for removing directories. | ||
|
||
make sure you are in the food directory | ||
Make sure you are in the food directory | ||
```base | ||
food % rm -r .git | ||
(base) mary food % ls -a | ||
|
@@ -172,7 +182,7 @@ Output | |
``` | ||
Now there is only the parent directory (recipes) that is a Git directory and we can use Git as main branch. | ||
|
||
Another way (which is recommended ) is to go one directory ahead (ie recipes) and we remove the .git repository at foods. ALWAYS CHECK with **pwd** | ||
Another way (which is recommended) is to go one directory ahead (ie recipes) and we remove the .git repository at foods. ALWAYS CHECK with **pwd** | ||
|
||
``` bash | ||
cd .. | ||
|
@@ -193,8 +203,8 @@ Output | |
```bash | ||
. .. curry.md pizza.md | ||
``` | ||
This is recommended when there are many nested git directories in the parent (ie recipes) | ||
But be careful the syntax! Running this command in the wrong directory will remove the entire Git history of a project you might want to keep. Therefore, always check your current directory using the command pwd | ||
This is recommended when there are many nested git directories in the parent (ie recipes). | ||
But be careful the syntax! Running this command in the wrong directory will remove the entire Git history of a project you might want to keep. Therefore, always check your current directory using the command `pwd`. | ||
|
||
In this section we present: | ||
|
||
|
@@ -205,10 +215,11 @@ In this section we present: | |
|
||
Key Points | ||
|
||
Use **git config -- global** can configure a user name, email address, editor, and other preferences once per machine. | ||
**[DW]** The first three are not covered in this episode[/DW] | ||
|
||
**git config -h** Opens the use of the config, Opens the Git manual | ||
**git config --help** | ||
**git init** initializes a repository. | ||
Git stores all of its repository data in the **.git** directory. | ||
**rm -r .git** # Removes the git directory (rm -r <directory name>) | ||
* Use **git config -- global** to configure a user name, email address, editor, and other preferences once per machine. | ||
* **git config -h** Opens the use of the config, Opens the Git manual | ||
* **git config --help** | ||
* **git init** initializes a repository. | ||
* Git stores all of its repository data in the **.git** directory. | ||
* **rm -r .git** # Removes the git directory (rm -r <directory name>) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no figures in a fig subdirectory of this repository. The directory and the png need to be added.