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

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.
主站蜘蛛池模板: 霍城县| 凤城市| 凤山县| 柘荣县| 桃园县| 拜泉县| 新宁县| 甘洛县| 镇坪县| 穆棱市| 漳州市| 子长县| 德庆县| 金沙县| 陆河县| 灵山县| 淄博市| 洞头县| 揭西县| 筠连县| 玛纳斯县| 二连浩特市| 潍坊市| 东明县| 通城县| 元江| 大新县| 兴仁县| 包头市| 高雄县| 汶川县| 娱乐| 吴堡县| 长子县| 安溪县| 沁阳市| 渝北区| 巴塘县| 佛冈县| 开远市| 海淀区|