官术网_书友最值得收藏!

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:

The Git GUI, while functional, does not give you all that much. The GitHub Desktop and SourceTree clients give you so much many options and are a lot prettier to look at. Another one that is worth checking out is GitKraken ( https://www.gitkraken.com/). GitKraken is completely multiplatform (it works on Windows, Mac, and Linux) and integrates with both GitHub and BitBucket. Unfortunately, GitKraken is only free for open source, education, non-commercial, and private projects.
主站蜘蛛池模板: 拉孜县| 延津县| 嘉黎县| 电白县| 吉林市| 泽普县| 辽宁省| 扶风县| 泰兴市| 汉源县| 六安市| 西宁市| 乌审旗| 安化县| 曲麻莱县| 太康县| 德令哈市| 徐汇区| 华池县| 盐山县| 横峰县| 长治市| 乐安县| 潮州市| 永胜县| 观塘区| 金山区| 大名县| 新营市| 霍城县| 措勤县| 双牌县| 蒙城县| 赤城县| 英吉沙县| 井陉县| 汶川县| 扬州市| 庄浪县| 荥阳市| 讷河市|