{F313836,layout=center}
A small depo for git demo
Recent Commits
Commit | Author | Details | Committed | ||||
---|---|---|---|---|---|---|---|
0266eedc8a00 | nepa | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
724aed2884f9 | nepa | merge | Oct 2 2015 | ||||
4b19b2e169a5 | ndubois | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
678bbbbd1de0 | ndubois | ioiswerhjfoi | Oct 2 2015 | ||||
cb6470effacf | pierre.amey@epfl.ch | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
665d2c13a887 | pierre.amey@epfl.ch | Creation d'un conflit | Oct 2 2015 | ||||
9bdc9fd80646 | nepa | test merge | Oct 2 2015 | ||||
809a0ab00b25 | sbancal | modif très importante! | Oct 2 2015 | ||||
7b5d23d91b24 | ndubois | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
019a87856cb4 | ndubois | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
5c9c05224ac7 | pierre.amey@epfl.ch | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
9e2b67984f72 | sbancal | Merge branch 'master' of gitlab.epfl.ch:sti-it/git-demo | Oct 2 2015 | ||||
ca05372a32e9 | pierre.amey@epfl.ch | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
01f26bfa720b | ndubois | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 | ||||
9b3da80400db | pierre.amey@epfl.ch | Merge branch 'master' of https://gitlab.epfl.ch/sti-it/git-demo | Oct 2 2015 |
README.md
% git-demo % Nicolas Borboën <nicolas.borboen@epfl.ch> % 2015-09-14
<!-- ===================================================================
_ _ _ (_) | | | __ _ _| |_ ______ __| | ___ _ __ ___ ___ / _` | | __|______/ _` |/ _ \ '_ ` _ \ / _ \ | (_| | | |_ | (_| | __/ | | | | | (_) | \__, |_|\__| \__,_|\___|_| |_| |_|\___/ __/ | |___/ $ git clone https://gitlab.epfl.ch/sti-it/git-demo.git To generate the PDF file please use this pandoc command $ pandoc --toc -V documentclass=report -o README.pdf README.md
=================================================================== -->
Git-demo project
The aim of this repo is to provide a simple tutorial about git usage. You will need git^[Information about installing git on your system can be found here: https://git-scm.com/download/] and a merge tool^Many merge tool are available but [Meld is a good multi-plateforme candidate].
Define your git public informations
- Set you username
$ git config --global user.name "Your Name Comes Here"
- Set you email
$ git config --global user.email you@yourdomain.example.com
Basics commands
This section present all the "every day" git commands. How to clone a git repository locally, add files, commit changes, push to repository and pull from repository.
- Create a projet on gitlab.epfl.ch / github.com or initialize a local project with the command
$ git init
- Clone the project on your computer
$ git clone username@host:/path/to/repository
$ git clone https://gitlab.epfl.ch/sti-it/git-demo.git
- Edit the file foo.md
- Commit your modification
$ git commit -m "My modifications details" foo.md
- Create a new file
$ vim myTestFile.txt
- Add the new file to git
$ git add myTestFile.txt
and commit it.
- Check your modification
$ git status
- Push your modification
$ git push
- Browse to the repository page to see the modification
- Others collaborators of the repository can now update their files to see your changes with
$ git pull
- Read the log
- View all the logs
git log
- View the log of a specified author
git log --author=bob
- Test some logs option
git log --pretty=oneline
git log --graph --oneline --decorate --all
git log --name-status
git log --help
- Note that you can use the following command to search for strings in any version of your project:
$ git grep "hello"
- Conflicts management
- Reset changes you made to a file
$ git checkout -- <filename>
- Set the tool you want to use to resolve conflict
$ git mergetool
- Resets any changes to tracked files:
$ git reset --hard origin/master
Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.
- If you want to be more delicate than the latest command, you can use:
$ git revert <commit>
Reverting has important advantages over resetting as it doesn’t change the project history, which makes it a “safe” operation for commits that have already been published to a shared repository.
- Managing branches
- Create a new branch
$ git branch myTest
- List the branches of your project
$ git branch
myTest master* (<-- current branch)
- Change the branch with the command
$ git checkout myTest
- Now edit the foo.md file and commit it, then change back on master branch
$ git checkout master
Check that the change you made is no longer visible, since it was made on the myText branch and you’re back on the master branch.
- Now you can edit files on the master branch, but at one point you may want to bring back the changes made on myTest to master branch:
$ git merge myTest
If the changes don’t conflict, you’re done. If there are conflicts, markers will be left in the problematic files showing the conflict.
- Check the markers with the diff command:
$ git diff
- Now edit the file to resolve the conflicts and commit the changes made to the file. You can use the tool "gitk" to graphically see the resulting history.
$ gitk
- As the changes made to the myTest branch are now merged, you can delete this branch:
$ git branch -d myTest
- Cleaning up
- Remove branches
$ git branch
and
$ git branch -D <every branches but master>
- Revert the changes made to foo.md and commit them
$ git reset fd0dec5 foo.md
<!-- ## Submodules https://git-scm.com/book/en/v2/Git-Tools-Submodules
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
-->
Documentation and links
- RTFM
- man git
- man 7 gittutorial
- man 7 gitworkflows
On the www
- Official
- Documentation
- Books
- Cheat Sheets: EN - FR
- Good alternative documentation
- Roger Dudler
- Atlassian
- gitmagic
- Courses
- GitHub
- CodeSchool
- Git Immersion
- Documentation in French
- OpenClassRooms
- Polytechnique.fr
- gitmagic
- PutainDeCode
- Submodules vs Subtree