GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.gitlab.com — Tutorial: Make your first Git commit | GitLab Docs
/ Tutorial: Make your first Git commitThis tutorial will teach you a little bit about how Git works. It walks you through the steps of creating your own project, editing a file, and committing changes to a Git repository from the command line. When you’re done, you’ll have a project where you can practice using Git. Before you begin
What is Git?Before we jump into steps, let’s go over some basic Git concepts. Git is a version control system. It’s used to track changes to files. You store files, like code or documents, in a Git repository. When you want to edit the files, you clone the repository to your computer, make the changes, and push your changes back to the repository. In GitLab, a Git repository is located in a project. Each time you push a change, Git records it as a unique commit. These commits make up the history of when and how a file changed, and who changed it. %%{init: { "fontFamily": "GitLab Sans" }}%%
graph LR
accTitle: Repository commit history
accDescr: Flowchart showing linear changes to a repository history
subgraph Repository commit history
direction LR
A(Author: Alex<br>Date: 3 Jan at 1PM<br>Commit message: Added sales figures<br> Commit ID: 123abc12) ---> B
B(Author: Sam<br>Date: 4 Jan at 10AM<br>Commit message: Removed old info<br> Commit ID: aabb1122) ---> C
C(Author: Zhang<br>Date: 5 Jan at 3PM<br>Commit message: Added invoices<br> Commit ID: ddee4455)
end
When you work in a Git repository, you work in branches. By default, the contents of a repository are in a default branch. To make changes, you:
%%{init: { "fontFamily": "GitLab Sans" }}%%
flowchart LR
accTitle: Use branches in Git
accDescr: The flow of creating, then using, a branch in Git
subgraph Default branch
A[Commit] --> B[Commit] --> C[Commit] --> D[Commit]
end
subgraph My branch
B --1#46; Create my branch--> E(Commit)
E --2#46; Add my commit--> F(Commit)
F --3#46; Merge my branch to default--> D
end
If this all feels a bit overwhelming, hang in there. You’re about to see these concepts in action. StepsHere’s an overview of what we’re going to do:
Create a sample projectTo start, create a sample project in GitLab.
Clone the repositoryNow you can clone the repository in your project. Cloning a repository means you’re creating a copy on your computer, or wherever you want to store and work with the files.
Create a branch and make changesNow that you have a copy of the repository, create your own branch so you can work on your changes independently.
Commit and push your changesYou’ve made changes to a file in your repository. Now it’s time to record those changes by making your first commit.
Your branch is now available on GitLab and visible to other users in your project. Merge your changesNow you’re ready to merge the changes from your
For this tutorial, you merge your branch directly to the default branch for your repository. In GitLab, you typically use a merge request to merge your branch. View your changes in GitLabYou did it! You updated the Let’s look in the UI and confirm your changes. Go to your project.
Now you can return to the command line and change back to your personal branch
( Don’t worry if you mess things up. Everything in Git can be reverted, and if you find you can’t recover, you can always create a new branch and start again. Nice work. Find more Git learning resources
Was this page helpful?
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |