#Git workshop
In this workshop you will learn the basics of git and git feature branch workflow.
- Git bash and basic commands
- Setup new local repositary
- Working with remote repositary
- Merging and resolving conflicts
- Feature branch workflow intro
- SourceTree application intro
=============
- Create github account at http://www.github.com
- Ask your supervisor to add you as a collaborator to project
- Download and install Git at https://git-scm.com/downloads
- Download and install SourceTree application at https://www.sourcetreeapp.com/download/
This task will introduce you to the basics of git local repositaries, how to create git repositary and work with your changes
- create empty folder named git_workshop
- inside create another folder task_1
cd task_1and initialize the git repositary to track any changes done to this folder- you can use
git statuscommand to check what has been done" - create game.txt, alzak.txt and player.txt files (in bash you can just
touch alzak.txt) - run
git status. You should see 3 untracked files - Add game.txt to the staging area
- Use
git committo save your work on game.txt in the history (-mparameter helps you to add message without opening any console editor) - Use
--allparameter to add alzak.txt and player.txt to your staging area. They share similar functionality therefore it's good to add them as a separate commit. It's logical! - Commit your files with any message you want.
- Create branch laser_gun
git checkout -b <branch>. Then checkout back to master - Make some changes to player.txt (e.g. add knife) and commit them. Hint: use
-aparam to add file and commit at once - Checkout to laser_gun, make changes to player.txt (add blaster to players arsenal), commit your changes.
- Now switch to master and try to merge your laser_gun branch. (you can run
git statusto make sure you don't have any uncommited changes on master).git merge <branch> - You have CONFLICT.
git statuswill tell you more detailed info as always. Open player.txt and try to resolve your conflict. - If you are confident about your resolution, commit it. You can
cat player.txtto check the file.git logcommand will show nice history. Congratulations, you are now ready to kill that monster!
- Clone project to a sourceTree application (github project url provided by supervisor)
- Click Git Flow to setup Feature Branch workflow
- Click Git Flow again to create feature branch called [your_github_user_name]_move_system
- Create new file called **[your_github_user_name].txt and add your Real name to it's content.
- Commit your changes with message "[your_github_user_name] adding new feature"
- Push your feature branch to origin
- Go to your github account and create a Pull request to DEVELOP branch Wait for code review / approval and merge by your supervisor
- Click Fetch in menu to see what happened
- Pull changes from origin
- Create new feature branch [your_github_user_name]_boosting_player and change player.txt so it contains new line with "name: [your_github_user_name]". Commit your changes. If line already exists, just change the name
- Create sub-branch from feature branch and add [your_github_user_name]_2.txt file
- Commit changes and merge the sub-branch to feature branch. (HINT: you need to be on feature branch)
- Push your feature to origin, create pull request to develop branch.
- Wait for supervisor, then Fetch from origin
- Pull changes to develop (and master if needed)
- Checkout to your feature branch and Pull from develop.
How to become advanced in git: read https://www.atlassian.com/git/tutorials/
How to become pro in git: practice, practice, practice