The folowing exercises will contain example code in bash. Available trough git bash on windows if you installed git. Though perform the "git ..." commands in e terminal as writen to learn whats intended about git.
edit: i
save and quit: <esc>, :wq<enter>
quit: <esc>, :q<enter>
quit drop changes: <esc>, :q!<enter>
Read trough the exercise first. There is an option at the end.
Create a new folder and move into it in you terminal.
mkdir git2days
cd git2daysInitiate a new git repository in the folder
git initCheck what branches are in your new repository
git branchCheck current status
git diff
git status
git logCreate a file
touch file.txtCheck current status and log
git diff
git status
git logStage the file
git add file.txtCheck current status
git diff
git status
git logCommit the file
git commit -m "file created"Check current status
git diff
git status
git logThis is an extra exercise if you have time.
It might be a little hard, but don't let that stop you from trying.
If the standard exercise seams too easy start here.
Do the exercise 1 with the following modification
after the setup part of exercise 1, also: move into the .git folder
cd .gitinit a git repo inside
git initadd everything in the .git folder to git.
git add .
git commit -m "new repository"
move out of the .git folder
cd ..after each part (eg. setup/working directory...)
cd .git
git diff
git status
git add .
git commit -m "..."
cd ..what has changed in the .git folder?
Read trough the exercise first. There is an option at the end.
now tag you commit.
git tag v0.1view you tags
git tagmake a new commit
touch file2.txt
git add file2.txt
git commit -m "another commit!"make an annotated tag on your new commit
git tag v0.2 -m "another tag!" This is an extra exercise if you have time. It might be a little hard, but don't let that stop you from trying. If the standard exercise seems too easy start here.
If you did not do meta git in exercise 1 you have to start with the setup step from that.
then do excersise 2 doing "check .git" after each part.
This is an extra extra exercises if you have extra time. It might be a little hard, but don't let that stop you from trying.
if the gpg commands fail.. install gpg https://www.gnupg.org/download/
check if you have key
gpg --list-keysif you didn't have a key, create a new one.
gpg --gen-keyconfigure git to use your key
git config --global user.signingkey 0A46826Anow create a signed tag..
git tag -s v1.5 -m 'my signed 1.5 tag'You can also sign a commit, file or folder. Read more: https://git-scm.com/book/uz/v2/Git-Tools-Signing-Your-Work
Form a group with 3-5 people.
Discuss and make a list of what workflows and what branches that are
- needed in your daily work
- bad for your daily work
How does that compare to how you work today?
Read trough the exercise first. There is an option at the end.
Create a new branch from your existing one
git branch ex4Create a new commit on master
touch ex4master.txt
git add ex4master.txt
git commit -m "another commit!"look at your log
git log --oneline --graphMove to your new branch
git checkout ex4Create a new commit
touch ex4.txt
git add ex4.txt
git commit -m "another commit!" look at your log
git log --oneline --graphgit log --oneline --graph ^master ex4
git log --oneline --graph ^ex4 mastergit rebase mastergit rebase ex4 masterThis is an extra exercise if you have extra time. It might be a little hard, but don't let that stop you from trying. If the standard exercise seams to easy start here.
If you did not do meta git in exercise 1 you have to start with the setup step from that one.
Then do excerise 4, doing "check .git" after each part.
Start working on a new branch
git branch ex5
git checkout ex5Create a new commit
touch ex5.txt
git commit -m "another commit!" ex5.txtgit checkout mastertry to merge with --ff-only
git merge ex5 --ff-onlywhat happens?
merge
git merge ex5 --ff-onlylook at your log
git log --oneline --graphSign up(or sign in) for github https://github.com/join
Fork https://github.com/paven/git2-exercise
then clone your for https://github.com//git2-exercise
make sure you are at the master branch
```bash
git branch -v
###merge
git merge origin/mergeMe
git log --oneline --graphpush
git push###now with rebase
git checkout -b rebaseMe origin/rebaseMe
git rebase master
git checkout master
git merge rebaseMe --ff-only
git log --oneline --graphpush
git pushWorking with detached head will speed stuff up and leave less trails
git checkout origin/rebaseMeDetached
git rebase origin/master
git log --oneline --graph
git push origin HEAD:masterDo a commit and then redo the rebase and the push This work flow lets you work more directly with the remote
git checkout origin/rebaseMeConflict
git rebase origin/master
git log --oneline --graphresolve the conflicts and continue:
git push origin HEAD:masterYou could also try this with merge
git merge origin/mergeMeConflictresolve the conflicts and continue:
git log --oneline --graphpush
git pushJoin up in pairs for this exercise.
Participant A gives access to their remote to Perticipant B. https://help.github.com/articles/adding-collaborators-to-a-personal-repository/
Adds A's remote to B's local repository.
git add coleage git clone https://github.com/<colleage>/git2-exercise
cd git2-exercise- write a commit and post it to A's remote
- rebase A's rebaseMeCollege on to B's master
add an existing repo/branch as a submodule
git submodule add -b submoduleBranch https://github.com/paven/git2-exercise.git theModulemeta information in repo
cat .gitmodules
ls .git/modules/init
git submodule initThen commit the added submodule
git commit -m "add submodule"Open your personal ~/.gitconfig
what does it contain? compare with another participant
open the local repo's config .git/config
git config -ewhat does it contain?
In the repo's config (so that we don't change global preference) .git/config
change editor (replace nano with your preference)
git config core.editor nanoYou can try your editor config out by doing a commit without a predifined commit message
git config core.editor nano