{no densequote} ## Git {libyli} -SVN-Git migration in progress. 8h to retrieve full SVN history,
less than 1min to push full history to Git (same network)!
{densequote} - History of Git - open source - initiated by Linus Torvalds - first release: 7 April 2005 - version 2.9.3: 12 August 2016 - fast and efficient - most used - Good alternative: mercurial (hg) # @copy:#plan: %+class:inred: .git ## Starting with Git {libyli} - Initializing your projectGit (/ɡɪt/) is a distributed revision control and source code management (SCM) system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005, and has since become the most widely adopted version control system for software development.
wikipedia
git init- What's up?
git status- Deciding what is relevant
git add file1 file2 …- first: introduce yourself ## Let's try it // script "simple.txt"
git commit
cp -r base mypaper ; cd mypaper git init git status git add mypaper.tex cvpr.sty git status git commit git status ... and more… ## Recap {libyli} * Beginning
git init* Working
git add ...
git commit [-m ...]
git status## Recap 2 {libyli} - Keep your project clean: ignoring files - **.gitignore** file(s) - **blabla.* ** , **!blabla.my_precious**, ** *~** - What did I just modify?
git add ...
git commit [-m ...]
git status- What happened?
git diff [...]
git log## Nota Bene (vs CVS, Subversion) {libyli} - You have the complete repository - have all commits locally - commit often, fast and everywhere (train, plane, here) - merge with 0-stress - warning: commit ≠ backup - Need to “**git add**” modifications - Repository == project - SVN has a big tree-shaped repository - SVN allows to "checkout" any subtree - Git works at the repository level - you'll have a set of repository - commits are at the repository level ## Tools for Git - GUI - Bundled with git: `git gui` and `gitk` // maybe not anymore - Many others (gitg, qgit, GitX, tortoisegit, Netbeans, ...) - graphical user interfaces for Git - huge list of frontends and tools - Help for installation - for Windows, use "gitbash" - details and video helper in the software carpentry instructions ## Customizing Git {#introduceyourself libyli} - Introducing yourself
git config --global user.name "John Doe"- Fancy colors and shortcuts
git config --global user.email john@doe.com
git config --global color.ui true- Configuration in **~/.gitconfig** - Software Carpentry help about configuring git # @copy:#plan: %+class:inred: .multigit ## About History {libyli} - Remember **git log**? - Each commit is written in stone - parent(s) commit - modifications - sha1sum (e.g. cb6dc3cb1f4f5eb15c1d9b2b25ae741cd73c0554)
git config --global alias.st status
git config --global alias.ci commit
git diff cb6dc3...- can be retreived
git checkout cb6dc3...## Back to the Future: parallel universes
git log gitk # or gitg git checkout 41474a33e098689b... emacs paper.tex git commit gitk gitk --all ... and more… ## Recap - Branch - a label for a commit - automatically follows on new commit (**git commit**) - Always commit before merging - commit is cheap, easy and local - you never loose anything when merging // maybe your temper - Use of “sha1” or branch-name (e.g. brrrr) - Shortcuts (about ^ and ~)
cb6dc3, brrrr, HEAD,## Recap 2 - Moving in the history
HEAD^, HEAD~, HEAD~~, HEAD~2, HEAD~42,
HEAD^2, cb6dc3^42, tagggg
git checkout sha1-or-branch-name- Creating a new branch at current position
git checkout -b new-branch-name- Merging “brrrr” into “master”
git checkout master## Recap 3 - Non-conflicting **git merge** ⇒ automatic commit - Conflicting **git merge** - (partial merge) - non-conflicting changes are automatically added - you: solve conflict - you: `git add` - you: `git commit`
git merge brrrr
{no densequote} ## Let's Go - Create a repository on GitLab - Push our content - link our repository to the remote repository (on GitLab) - push the changes to this remote repository - On another machine - clone the repository - make changes, commit and push them - On this machine - pull changes: fetch them and then merge ## Recap GitLab (and Git remotes) {libyli} - GitLab project == git repository (+ wiki etc) - The local repository can be linked to some remote one(s) - When we `git clone`, a remote named `origin` is set up - When we `git fetch`, we download the remote changes - ... we can then use `git merge` to integrate them - ... or `git pull` that does fetch+merge - When we `git push`, we upload our history of changes to the remote - Reminder: always commit before merge or pull ## More GitLab (additions to git) {libyli} - Groups - groups of users (e.g., PhD student and supervisors) - automatic access to the projects of the group - Forking - take a repository on GitLab - make a “personal” copy of this repository (still on GitLab) - Merge requests (pull requests in GitHub) - ask for another repo to integrate changes from your fork - Issues - bug - questions - feature requests - Wikis - set of pages, in markdown - (also accessible as a git repository) ## Things to Know at UJM {ujm libyli} - SSH access is disabled - always use "https://gitlab...." to clone your repository - To avoid typing your login every time - add your user name and @ after https:// - e.g., - git clone https://**er1234h@**gitlab.univ-st-etienne.fr/remi.emonet/pyqtidoteach.git {denser no} - in case you forgot, you can edit **.git/config** - In case of problems while pushing big sets of commits -GitLab offers git repository management, code reviews, issue tracking, activity feeds, wikis.
error: RPC failed; result=22, HTTP code = 411 fatal: The remote end hung up unexpectedly- just run **git config http.postBuffer 524288000** ## How to Get an Account on GitLab {ujm libyli} - For people with a UJM account - open a ticket and asking “to get an account on GitLab” - wait until you're notified it has been done - visit http://gitlab.univ-st-etienne.fr/ - use your UJM login/pass to connect - ignore the email you'll receive about validating your email - For other people (interns, external collaborators) - a person from UJM needs to open a ticket asking for the account - providing an email and a name (for each collaborator) - upon creation, you receive your credentials - to log in, visit https://gitlab.univ-st-etienne.fr/ - click on the “Standard” tab - use the credentials you've been given - In the near future - LDAP users: automatic access - other users: unified management across all university services # @copy:#plan: %+class:inred: .concl ## Key Points {#key key deck-status-fake-end} - Version control - keep track of what happened - store semantic snapshots/versions of your “code” - Git - “distributed” version control: you have a complete repository - efficient and widely used - one repository per project - GitLab : a place to share repositories (projects) - visualization of the repositories, wiki pages, issue tracker, … - groups of users (e.g., PhD student and supervisors) - Links - interactive learning of branching in Git - official website - graphical user interfaces for Git - for Git by a git, ask Linus Torvald - Pro Git book (available online) ## Correspondence git ⇄ svn {libyli} - git commit ⇄ none - git commit ; git push ⇄ svn commit - git fetch ⇄ none - git fetch ; git merge ⇄ svn update - git pull == git fetch ; git merge - {no} - NB: you can also use git to collaborate with SVN users, using "git svn" ## Going further - git remote add - git tag - git rebase - git commit --amend - git reflog - git ls-files - git revert - git bisect
/ − will be replaced by the title
−