A basic Git workshop
open http://ffg/ for handout
git config --global user.name "Your Name"
git config --global user.email user@domain.tld
Git is a distributed system, so it uses email addresses to uniquely identify users.
git help config
git init repo
cd repo
This creates a new, empty repository which lives only on your computer (for now).
echo git > cool_stuff.txt
git status
git init without argument to start tracking existing files in ./
git add cool_stuff.txt
git status
git add
git add -p
git commit
git status
git add for files known to Git using git commit -a
gitk |
GUI | separate tool |
tig |
ncurses | separate tool |
git log |
text | included in git |
Every commit contains a snapshot of the entire repository; unlike checkins in RCS or Subversion, which operate on individual files or directories, respectively.
gitk)First line: very short summary, what changed?
After a blank line follows the answer to the "why". What was
the motivation for the change? How is the need addressed by
this commit?
If applicable: Which alternatives were considered, and why
were they discarded?
Closes #bugid.
git config --global user.name "Your Name"
git config --global user.email user@domain.tld
git revert HEAD~1. What does it do? Can you revert other changes?
.git directory - what changes at each step?
git clone git@ffg:ffg/hello.git
cd hello
ls
git status
This has created a clone of the hello.git repository. The repository we cloned from is called its origin.
.git, while repositories we can make commits in do not.
git pull
* 8c577b0 Merge branch 'master' of ↵
http://ffg/gogs/ffg/hello.git
|\
| * b983d4c Linux is also cool
* | e8fa16e Start collecting numbers
|/
* 3adcc80 My second git commit
* b323f69 My first git commit
git log --graph --oneline
git pull
In cool_stuff.txt:
Tübix
Git
<<<<<<< HEAD
reveal.js
=======
Linux
>>>>>>> b983d4cc25261780d3b2a21a142d4750394c5c77
git mergetool
git commit
git push
# ...
# To git@ffg:ffg/hello.git
# d039e72..325b819 master -> master
git push
# ...
# To git@ffg:ffg/hello.git
# ! [rejected] master -> master (non-fast-forward)
# error: failed to push some refs to 'git@ffg:ffg/hello.git'
# ...
cool_stuff.txt (this should give conflits which you need to resolve)git log --graph --oneline
* 5567e85 (HEAD -> master) My third git commit
* df5a1e0 My second git commit
* d3a1a32 My first git commit
git branch feature master~2
git checkout feature
$EDITOR; git commit -a
* 16ae900 (feature) Commit on feature branch
| * 5567e85 (master) My third git commit
| * df5a1e0 My second git commit
|/
* d3a1a32 My first git commit
git checkout master
git merge feature
Git merges histories of the entire repository; until all conflicts are resolved and committed, the merge is “in progress” for all files.
git merge --abort
git checkout feature
git rebase master
git checkout master
git cherry-pick feature