# hello **Repository Path**: lundechen/hello ## Basic Information - **Project Name**: hello - **Description**: how to install clion and git - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 11 - **Forks**: 0 - **Created**: 2021-07-21 - **Last Updated**: 2024-08-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Setup CLion and git for C/C++ programming ## 0. Instruction Video ![](img/bilibili.PNG) Watch the instruction video on Bilibili: - https://www.bilibili.com/video/BV1cq4y1S7Be ## 1. Download installation files ![](img/download.png) #### Windows: 1. Download CLion 2020.1 - https://download.jetbrains.com/cpp/CLion-2020.1.exe 2. Download Codeblocks with MinGW - https://sourceforge.net/projects/codeblocks/files/Binaries/20.03/Windows/codeblocks-20.03mingw-setup.exe/download 3. Download git for Windows - https://gitforwindows.org/ 4. Download jetbrains-agent.jar - https://gitee.com/lundechen/hello/blob/master/jetbrains-agent.jar #### MacOS: 1. Download CLion 2020.1 - https://download.jetbrains.com/cpp/CLion-2020.1.dmg 2. Download jetbrains-agent.jar - https://gitee.com/lundechen/hello/blob/master/jetbrains-agent.jar #### Baidu YunDisk: ![](img/baidu.PNG) You can also download those files from Baidu YunDisk: - 链接:https://pan.baidu.com/s/1Io2OLFG7c9VtHiwCGQ1iGQ - 提取码:jhhs ## 2. Install a C/C++ compiler #### Windows: ![](img/mingw.png) - Install CodeBlocks with MinGW (Windows only). - **Don't change the default installation path.** #### MacOS: Install XCode, or, Xcode command line tools: - https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-macos.html#debugger ## 3. Install CLion ![](img/clion.png) You can install it at any location you want. ## 4. Install Git ![](img/git.png) #### Windows: Install git for Windows. You can install it at any location you want. #### MacOS: On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time. 苹果电脑,打开终端,输入如下命令: ```shell script git --version ``` If you don’t have it installed already, it will prompt you to install it. ## 5. Activate CLion 1. Open CLion. 2. Input an email address (not necessarily a valid one, for example, `randomstuffhahahahha@whateverhahahah.com`). 3. Create a C or C++ project. 4. Drag `jetbrains-agent.jar` from the File Explorer to CLion project. Then restart CLion. ## 6. Git clone the "hello" repository In CLion menu, click `VCS`->`Get from Version Control`, and enter this URL: ```shell script https://gitee.com/lundechen/hello.git ``` Then proceed to click on the `clone` button. ## 7. Run the "hello" program You should now be able to run the "hello" program that you have just now cloned from gitee.com. If not, go to the menu ```File```->```Settings```->```Build, Execution, Deployment```->```Toolchains```, to check if ```Make```, ```C/C++ Compiler``` and ```Debugger``` are found. If not, click the ```...``` on Environment option, and select the directory where your MinGW is installed. **Attention: you should log in to Windows with a user name composed of English alphabet letter and digit numbers, and NO Chinese characters. Or else, CLion won't be able to find your MinGW.** :rocket: :rocket: Windows 用户名,请不要含有汉字或其他特殊字符,最好只有英文字母和数字。 - How to know your Windows user name? - [9 Easy Ways to Find Your Windows Username](https://www.technewstoday.com/find-windows-username/) - [What Is My Windows Username?](https://www.minitool.com/news/what-is-my-windows-username.html) :rocket: :rocket: 新建或克隆项目的路径,请不要含有汉字或其他特殊字符,最好只有英文字母和数字。比如```D:\hello```。 :rocket: :rocket: 使用汉化版可能带来未知问题。遇到汉化版的问题,请先尝试卸载 CLion,再次安装原版。 ## 8. Useful git commands ![](img/bilibili.PNG) Watch the instruction video on Bilibili: - [:rocket: :rocket: B站视频-编程课程使用Git-师生交互-简单场景-以算法入门为例](https://www.bilibili.com/video/BV1gu411Q7T3/) #### For TD class: For the course of Introduction to Programming course (LO01), you should learn to use those two very simple commands: ```shell script git stash ``` ```shell script git pull ``` If you want to save your code to a local branch, you should configure your username and email: ![](img/gitconfigemail.gif) and learn to manipulate with ```shell script git add ``` ```shell script git commit ``` ```shell script git checkout ``` ```shell script git reset --hard origin/master ``` For the C++ course (LO02), all the above mentioned commands will be used, in addition to: ```shell script git fetch ``` ```shell script git branch ``` #### For your Project: ![](img/git-commands.png) You might need to push your code to gitee.com for your project of C++. And you would need to collaborate with your teammates for coding tasks. For doing this, you should first **register a gitee.com account using your mobile phone number.** The baseline is, when doing your project, you should also learn to use: ```shell script git clone ``` ```shell script git push ``` ```shell script git merge ``` ```shell script git remote ``` For other more complicated command lines, ask the professor for help. ## 9. [Optional] Git branch/status indicator on Terminal #### Windows: ![](img/ohmyposh.png) Install posh-git: - https://github.com/dahlbyk/posh-git - https://web.archive.org/web/20210701230047/https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup - [Tutorial: Set up Powerline in Windows Terminal](img/posh-git.pdf) - https://stackoverflow.com/questions/20949892/using-powershell-as-terminal-in-intellij-idea-ides-like-pycharm-phpstorm-or-rub For those who cannot install posh-git, you could install GitToolBox plugin for CLion, by: ```File```->```Settings```->```Plugins```->```Marketplace```-> Search "```GitToolBox```" -> ```Install```. ![](img/gittoolbox-1.png) Then you will have branch indicator as well. ![](img/gittoolbox-2.png) #### Linux & MacOS: ![](img/oh-my-zsh.jpg) Install ```oh-my-zsh```, which is quite easy to configure. - https://blog.csdn.net/qq_41996454/article/details/102640653 ## 10. [Optional] Git with ssh keys ![](img/ssh.png) - https://jdblischak.github.io/2014-09-18-chicago/novice/git/05-sshkeys.html - https://docs.joyent.com/public-cloud/getting-started/ssh-keys/generating-an-ssh-key-manually/manually-generating-your-ssh-key-in-windows#git-bash ```shell script ssh-keygen ```