Git crash course
Source Control Manager (SCM)
System for tracing changes on source code
graph TD; A[Remote repository]; B[User_1 local working copy]; C[User_2 local working copy]; A --> B; A --> C;
Advantages
- Reliable
- Backup
- Paralel development of different issues on the same project
Operations
update
(update the local version with the server version)checkout
(download a file to local in order to modify it)commit/check in
(add to the server)discard/revert
(undo local changes)
Git
Definition
- Offical Git page
- The system is distributed
- Free/Libre Software
- Branches (origin/master): the HEAD points the current working branch
graph TD; A[Remote repository]; B[User_1 local working copy]; C[User_1 local working copy]; D[User_2 local working copy]; E[User_2 local working copy]; A --> B; B --> C; A --> D; D --> E;
Operations
clone
fetch
stage
commit
push
Commands
Command | Action |
---|---|
git init |
Initialize local repository |
git remote add origin <url_remote_repo> |
Link local to remote repository |
git config [--global] user.name "UserNameRemote" |
Configure user credentials |
git config [--global] user.email "myMail@mail.com" |
configure mail on reporitory service |
git config [--global] user.name |
Check configuration |
git tag 1.0.0 <commitId> |
Name a status on the repository |
git tag |
Retrieve list of tags |
git status |
Check the latest status |
git clone /userrName@host:repository/path |
clone a remote repository |
git add myFile.txt |
adds a file to the stage (control version) |
git commit -m "My first commit" |
persist changes on the local repository |
git push origin master |
pesist the changes stored on the local repository to the remote repository |
git pull origin master |
retrieves the code from the remote repository and merge it with the local branch |
git branch myIssueFix |
creates an alternative path for your data and sets the HEAD there |
git checkout myPartnerFix |
changes the HEAD to a the selected branch |
git merge <myBranchContentNeeded> |
merges the content of branchContentNeeded into the current branch |
git request-pull <start> <url> [<end>] |
generates a summary of pending changes |
Useful alias to render logging
1 | [alias] |