- Continuous Integration,Delivery,and Deployment
- Sander Rossel
- 613字
- 2021-07-02 15:42:12
Using Git
Installing Git on Windows is easy enough. Simply head over to their website (https://git-scm.com/) and download the Windows installer. Run it and leave all the defaults. This will also install the Git GUI and the Git Bash.
Open up a Command Prompt. First, we need to identify ourselves to Git. Git has settings on three different levels, system, global, and local. The system settings are system-wide and apply to all Git repositories on the computer. The global settings apply to all the repositories for the currently logged in user. The local settings apply to a single Git repository. More specific settings override less specific settings, so system settings can be overridden by global and local settings, and global settings can be overridden by local settings. To identify ourselves, we are going to set the global settings user.name and user.email. After that, we can clone our Git repository (meaning we are copying it to our computer):
git config --global user.name "Your Name"
git config --global user.email "your.email@provider.com"
git clone http://ciserver/user/test.git desktop\myrepo
The link to your Git project can be found on the project page of GitLab. The desktop/myrepo part is optional and specifies a custom folder for your project. The default folder is the name of the Git repository in your current folder. Add a file to the folder Git just created. A simple text file will do. Now move to your repository with cd desktop\myrepo (or whatever folder you cloned to). The next thing we need to do is add the new text file to the repository; you can do this with git add . (the . means we are just adding all the files). You can now check out the status of your repository using git status. You will see that the text file needs to be committed. We can commit our changes using git commit -m "Some commit message". Because Git creates a local repository, we still need to push to commit to the server. We can do this using git push:
cd desktop\myrepo
git add .
git status
git commit -m "Added a text file."
git push
Here is output of the preceding commands:

Now, if you go back to GitLab, you should see your commit. If everything worked, you have successfully installed Git and GitLab!
Working from the command line is doable, but not very practical. Especially when you have got a big project with many files. When you use GitHub, you can use their GitHub Desktop. When you decided to go for BitBucket, you are probably using SourceTree. Well, Git has the Git Gui. With Git Gui, it is a lot easier to see which files need to be added, are changed, will be committed, and so on. When you open it, you can create, clone, or open a repository. Go for Clone Existing Repository, enter the repository URL and a non-existent folder, and the repository will be cloned to your computer:

The next window will show you your changes. When you make some changes to your text file, add another text file, and hit Rescan, you will see the files in the upper-left corner. You can click the icons to add or stage the files, after which you can commit and push:

- C及C++程序設(shè)計(jì)(第4版)
- 復(fù)雜軟件設(shè)計(jì)之道:領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)全面解析與實(shí)戰(zhàn)
- Objective-C Memory Management Essentials
- Docker and Kubernetes for Java Developers
- Internet of Things with the Arduino Yún
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- GeoServer Beginner's Guide(Second Edition)
- Building Serverless Applications with Python
- Kotlin編程實(shí)戰(zhàn):創(chuàng)建優(yōu)雅、富于表現(xiàn)力和高性能的JVM與Android應(yīng)用程序
- Mastering Unity 2D Game Development(Second Edition)
- 劍指大數(shù)據(jù):企業(yè)級(jí)數(shù)據(jù)倉庫項(xiàng)目實(shí)戰(zhàn)(在線教育版)
- Practical Microservices
- HTML5移動(dòng)Web開發(fā)
- ArcPy and ArcGIS(Second Edition)
- Scratch 3.0少兒積木式編程(6~10歲)