diff --git a/README.md b/README.md index c73b014f1b100c74197663ec142114cd31859f3b..097c8073934cb733234e38bbdc108d05a4007d4c 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,21 @@ Training material for the Git for Beginners ABiMS training session ### Trainee Setup Testing 1. Does everyone have an account on GitLab ? -### Git Basics +### Git(Lab) Basics 1. Some definitions 1. Creating a repository 1. Adding / editing / removing files & folders 1. Committing changes -### Using a Repository Remotely +### Using Remote Repositories 1. Motivation - 1. Cloning a repository - 1. Modifying the local repository + 1. Cloning a GitLab repository + 1. Cloning using HTTPS + 1. CLoning using SSH + +### Git Command Line Basics + 1. Displaying information about a local repository + 1. Making changes to the local repository 1. Propagating changes to the remote repository ### Branching Basics diff --git a/git-remote/README.md b/git-remote/README.md new file mode 100644 index 0000000000000000000000000000000000000000..70e1795cfbae73ccb18073174b9280dc5d2e58cb --- /dev/null +++ b/git-remote/README.md @@ -0,0 +1,62 @@ +# Working with Remote Repositories + +## Motivation + +When working on project files, it may be easier to manipulate the files locally, i.e. on your workstation. This is especially true for development projects (R, Python, Java) where you want to code/compile/run/debug your project on your workstation. Propagating your changes to the remote repository is a means to back up the most important files. + +This is also handy when you work on several different machines (your personal laptop, and a remote server) and want to be able to easily synchronize your project files. + +A more advanced usage is to work on several local copies of a remote repository simultaneously. Ex.: You are working on a new feature of your program (or a new chapter of your book), but you need to fix a bug in the current release of the same program (or you want to fix typos and other minor mistakes in another chapter). Git makes it easy to have two (or any number of) *distinct* copies of the same repository on your machine in completely separate folders, and allows you to make modifications in isolation before propagating your work back to the same remote repository. + +## Cloning a Repository + +Copying a remote repository is called *cloning*. In order to be able to clone a repository, you need its address (URL). For non-public repositories you may also need credentials (login/password, SSH key or other). + +The actual URL(s) for a GitLab hosted project can be found by clicking the `Clone` button, which provides two methods for cloning : HTTPS, and SSH + + + + +## Cloning using HTTPS + +The complete command to clone a repository from GitLab using HTTPS looks like: + +``` +git clone https://gitlab.com/<gitlab_username>/<gitlab_projectname>.git +``` +where: + - `gitlab_username` is the user name of the GitLab project ownder. + - `gitlab_projectname` is the "computerish" name of the project (no spaces or special characters, all lowercase by default) + +The command may ask you for your GitLab username and your password. + +[This video](./media/git-clone.mp4) shows how a clone operation of the tutorial project is performed. + + - The benefit of using HTTPS is that no further setup is needed on your workstation. + - The drawback is that unless you use advanced (and insecure) git commands to store your username and password, you will need to enter them every time you communicate with the remote repository. + +## Cloning using SSH + +Using SSH to interact with the repository required you to copy an SSH key file to GitLab. If you have no such key, you will have to generate it. + +The command to generate a key looks like: +``` +ssh-keygen -t ed25519 -f ~/.ssh/ed25519_gitlab +``` +And creates two files: a file with a secret key and a file with a public key. + +To display the contents of the file with the public key, use: +``` +cat ~/.ssh/ed25519_gitlab.pub +``` + +An example of how to generate a key pair and view the public key is given in the following screencast: + + + +This contents has to be copied to the GitLab SSH Key management page, accessible in the left panel of the User Settings page which can be displayed using `Edit profile` in the menu below the user badge (upper left corner). + +[This screencast](./media/gitlab-ssh.mp4) shows how to add an SSH key to GitLab + +The SSH private key must be present in the correct location on each machine (laptop, workstation) that will be used to access the GitLab repository. It is recommended to generate a key pair on each machine and to add each public key to GitLab. It avoids having multiple copies of a private key, and also allows to track which machine was used to access the repository. + diff --git a/git-remote/media/clone_button.png b/git-remote/media/clone_button.png new file mode 100644 index 0000000000000000000000000000000000000000..622f0714b85a878d855d2ed0dad9a13eaf50eda6 Binary files /dev/null and b/git-remote/media/clone_button.png differ diff --git a/git-remote/media/git-clone.mp4 b/git-remote/media/git-clone.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..da2633c6800361f3164b0e9b9f590dca5760194c Binary files /dev/null and b/git-remote/media/git-clone.mp4 differ diff --git a/git-remote/media/gitlab-ssh.mp4 b/git-remote/media/gitlab-ssh.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..9f6d52cb30225561855c206d7a5613a67b8efabb Binary files /dev/null and b/git-remote/media/gitlab-ssh.mp4 differ diff --git a/git-remote/media/gitlabssh.gif b/git-remote/media/gitlabssh.gif new file mode 100644 index 0000000000000000000000000000000000000000..6f684ef5ca889d87631b80908981d238df224778 Binary files /dev/null and b/git-remote/media/gitlabssh.gif differ diff --git a/git-basics/README.md b/gitlab-basics/README.md similarity index 96% rename from git-basics/README.md rename to gitlab-basics/README.md index d3408d497066a89369de754e0226b525bd9867a9..89e8bf8a9b8b6cd0c3dd5bff49ffba0f164b89c4 100644 --- a/git-basics/README.md +++ b/gitlab-basics/README.md @@ -26,13 +26,13 @@ Git provides operations to specify which files should be part of a commit. ## Create Your First Repository -### [Log In to GitLab](/git-basics/media/gitlab-login.mp4) +### [Log In to GitLab](./media/gitlab-login.mp4) Log in to GitLab using your favourite account settings (GitLab, Google, GitHub, Twitter...)  -### [Create a new Project](/git-basics/media/gitlab-create-project.mp4) +### [Create a new Project](./media/gitlab-create-project.mp4) 1. Select **Create a Project** 1. Select **Create Blank Project** @@ -76,7 +76,7 @@ The Web IDE provides all that is required to manipulate a project's files. The left panel shows a file explorer with at the top, buttons for: - Creating new files. - Uploading files. - - Creting new folders. + - Creating new folders.  @@ -120,20 +120,3 @@ Using the `Create commit...` allow to tune how modifications will be propagated Take some time to complete [the exercises](./exercises.md) - - - - - - - - - - - - - - - - - diff --git a/git-basics/exercises.md b/gitlab-basics/exercises.md similarity index 100% rename from git-basics/exercises.md rename to gitlab-basics/exercises.md diff --git a/git-basics/media/addition_icon.png b/gitlab-basics/media/addition_icon.png similarity index 100% rename from git-basics/media/addition_icon.png rename to gitlab-basics/media/addition_icon.png diff --git a/git-basics/media/commit_button.png b/gitlab-basics/media/commit_button.png similarity index 100% rename from git-basics/media/commit_button.png rename to gitlab-basics/media/commit_button.png diff --git a/git-basics/media/current_files.png b/gitlab-basics/media/current_files.png similarity index 100% rename from git-basics/media/current_files.png rename to gitlab-basics/media/current_files.png diff --git a/git-basics/media/edit_icons.png b/gitlab-basics/media/edit_icons.png similarity index 100% rename from git-basics/media/edit_icons.png rename to gitlab-basics/media/edit_icons.png diff --git a/git-basics/media/gitlab-create-project.mp4 b/gitlab-basics/media/gitlab-create-project.mp4 similarity index 100% rename from git-basics/media/gitlab-create-project.mp4 rename to gitlab-basics/media/gitlab-create-project.mp4 diff --git a/git-basics/media/gitlab-login.mp4 b/gitlab-basics/media/gitlab-login.mp4 similarity index 100% rename from git-basics/media/gitlab-login.mp4 rename to gitlab-basics/media/gitlab-login.mp4 diff --git a/git-basics/media/gitlab_create_project.png b/gitlab-basics/media/gitlab_create_project.png similarity index 100% rename from git-basics/media/gitlab_create_project.png rename to gitlab-basics/media/gitlab_create_project.png diff --git a/git-basics/media/gitlab_current.png b/gitlab-basics/media/gitlab_current.png similarity index 100% rename from git-basics/media/gitlab_current.png rename to gitlab-basics/media/gitlab_current.png diff --git a/git-basics/media/gitlab_login.png b/gitlab-basics/media/gitlab_login.png similarity index 100% rename from git-basics/media/gitlab_login.png rename to gitlab-basics/media/gitlab_login.png diff --git a/git-basics/media/gitlab_project_info.png b/gitlab-basics/media/gitlab_project_info.png similarity index 100% rename from git-basics/media/gitlab_project_info.png rename to gitlab-basics/media/gitlab_project_info.png diff --git a/git-basics/media/modification_icon.png b/gitlab-basics/media/modification_icon.png similarity index 100% rename from git-basics/media/modification_icon.png rename to gitlab-basics/media/modification_icon.png