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

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.
主站蜘蛛池模板: 公安县| 海原县| 年辖:市辖区| 甘德县| 明水县| 凉山| 西乌| 施秉县| 阳西县| 繁昌县| 东港市| 南京市| 专栏| 丰顺县| 靖远县| 略阳县| 鄂托克前旗| 手游| 尚志市| 资源县| 尚志市| 东兴市| 普兰县| 泰州市| 丹棱县| 府谷县| 盘锦市| 金华市| 资阳市| 巴东县| 姚安县| 车险| 巴林左旗| 靖州| 都安| 普格县| 万年县| 清流县| 全南县| 江达县| 昆山市|