5. Create folder git-workshop
• Create folder “git-workshop”
• Initialize a new repository git init
• Add a new remote repository: git remote add
origin gitosis@lifeline.su:git-workshop.git
Fetch the project
• Run command git fetch
• You will fetch all the repository with all branches
6. Workflow scheme
master dev Your Time
git merge dev branch
r
m aste
ebase
git r
7. Check status
• git status
Create your own branch
• git branch feature_JIRA-TASK-1234_make-
cool-website
• git checkout feature_JIRA-TASK-1234_make-
cool-website
• Or just git checkout -b feature_JIRA-TASK-
1234_make-cool-website
• Make changes, create files, adjust files
• Add new files to the repo: git add <filename>
8. Committing
• You can use git commit –m “My commit
message” –a command to make local commit
Pushing to server
• Pushing is as easy: git push origin
<branch_name>
Switch to dev branch
• git checkout dev
Pulling the changes
• git pull origin dev
9. Rebasing from dev
• We need to switch back to our own branch: git
checkout <your_branch>
• Rebase from dev: git rebase dev
Resolving the conflicts
• git add <resolved_filename>
• git commit –m ”Conflict resolved” -a
10. Merging into dev
• Go back to dev: git checkout dev
• Merge your changes into dev: git merge
<your_branch> --no-ff
Pushing to dev server
• git push origin dev
Merging into master
• Switch to master: git checkout master
• Merge with dev: git merge dev
11. Push to master branch
• git push origin master
Stash
• git checkout <your branch>
• Make changes in files
• git stash save “My humble changes”
• Check your repo status out: git status
• Look up all your stashes: git stash list
• Recover your stash: git stash apply <stash_#>