Version Control System
- Document_v1
- Document_v2
- ...
- Document_vfinal
- Document_vreallyfinal
- Document_vreallyfinaliwontmodifyitiswear
Version Control System
- Will be a requirement for any technical job
- Is independent from the programming language
- Git is the most prevalent VCS
- Github
- Online collaboration platform
- Millions of users
- A social network for developers
Git
Decentralized Version Control System
- Create a github account
- Fork https://gitub.com/QuantStack/cpp_dauphine
git clone <your_repo>
cd cpp_dauphine;
git log
Git
Create a "document_name.txt" into basics/git_tutorial/
(where name is replace with your last name)
that contains your first name and last name, and your github pseudo
git checkout -b my_branch
git add document_XX.txt
git commit -m "commit message"
Git
Do not execute the following lines, that's for illustration
Instead, go to https://github.com/QuantStack/cpp_dauphine and open a Pull Request
git checkout master
git merge my_branch
Git
Decentralized Version Control System
Git
git remote -v
git push origin my_branch
git remote add upstream http://github.com/QuantStack/cpp_dauphine.git
Git
git checkout master
git pull upstream master
git push origin master
git branch -d my_branch
git push origin :my_branch
Git
Git
git checkout master
git pull upstream master
git checkout dev
git rebase master
if and else
if(x > 0)
{
std::cout << "x is positive" << std::endl;
}
else if(x < 0)
{
std::cout << "x is negative" << std::endl;
}
else
{
std:cout << "x is 0" << std::endl;
}
while
#include <iostream>
int main(int argc, char* argv)
{
int n = 10;
while(n ≥ 0)
{
std::cout << n << std::endl;
--n;
}
std::cout << "end of loop" << std::endl;
}
do while
#include <iostream>
int main(int argc, char* argv)
{
int n = 0;
do
{
std::cout << n << std::endl;
--n;
}
while(n ≥ 0)
std::cout << "end of loop" << std::endl;
}
for
#include <iostream>
int main(int argc, char* argv)
{
for(int i = 0; i< 10; ++i)
{
std::cout << i << std::endl;
}
std::cout << "end of loop" << std::endl;
}
break
#include <iostream>
int main(int argc, char* argv)
{
for(int i = 10; i> 0; --i)
{
std::cout << i << std::endl;
if(i == 3)
{
std::cout << "countdown aborted" << std::endl;
break;
}
}
std::cout << "end of loop" << std::endl;
}
continue
#include <iostream>
int main(int argc, char* argv)
{
for(int i = 10; i> 0; --i)
{
if(i == 3)
{
continue;
}
std::cout << i << std::endl;
}
std::cout << "end of loop" << std::endl;
}
switch
int i = std::rand() % 2;
switch(i)
{
case 0:
std::cout << "i is even" << std::endl;
break;
case 1:
std::cout << "i is odd" << std::endl;
default:
std::cout << "default case" << std::endl;
}