- 1 Talk Git
- 2 art/design project using Git
- 3 install Git
- 4 Start Git
- 5 3 Git moments
- 6 Undoing things
- 7 resources
- 8 DAY 2: Remotes / collaboration
- 9 remote repositories
- What is Git? What do you imagine Git to be?
- Who uses Git?
- How is Git used?
art/design project using Git
- Open Source Publishing website
- Electric Puppet Theatre animation
- Julien Design with Git - NEEDS USE CASE
Git is installed when you install Xcode
to check if it is installed run in the command line:
If it responds with a version number, Git is installed
To start using Git, you need:
- a dedicated folder for you project, where all files and sub-folders of the project live
- navigate with the command line to that folder:
- initialize Git:
The last step with create a hidden
.git/ folder where all the Git data will be stored.
3 Git moments
For local (in your computer) Git operations, there are 3 main moments:
- working: editing files
- stage: adding (tracking) files to git
- commit: span-shooting the changes performed on files
Staging refers to the action of making files ready for commit.
git addwhen run for the 1st time on file or folder, it ask Git to start tracking it
- on a file that is being tracked, but has since changed, it include those changes to be commited
- There might be files you might not want to track and therefore you don't add them
git statusoverview or staged moment:
- displays tracked and untracked files
Trick: If you wanna stage from files which Git is tracking run:
git add -u
A commit is version of your project. When you complete some part of the work, you commit!
git commit -m "message about what happened in that commit"creates a version or commit of your project. A accompanying message describes what happen in that commit.
git logshow the history of commits, where each commit is shows an author, date, message and hash (a long string of letter and numbers that identifies the commit)
Unstage, means bring added changes out or the stage moment.
In other words, before commiting, the changes you made to a file, then
git add that.file, can be undone by running:
git reset HEAD file.name
Warning: those changes will be lost!
checkout a specific commit
The state of files in a specific commit can be checked out using:
git checkout commit-hash
This command will detach the HEAD (like the reading head of a K7) from the latest commit. In other words, it will let you go back in time to a previous commit.
To keep it simple, you can't do much there, but look around, copy content from files and save them in new (untracked) files.
When you are done, you can return the head to the latest commit by running
git checkout master
Reverts the head to a previous commit:
git revert commit-hash
But instead of erasing history, creates a new commit
DAY 2: Remotes / collaboration
Git facilitates the coordination of contributions from different collaborators in a project.
Each contributor has a local repository, that is a 'clone' of the remote repository.
The remote repository acts as the central node from which all the users will receive - pull - and send - push contributions.
creating a remote
In pzwart1 the git server is located in
With the repositories stored
To create a remote, 1 person(normally the admin) start a remote (bare) repository to push and pull code to and from:
cd /home/git/git mkdir null.git cd null.git git init --bare
set remote & first push
(Note: This step only needs to be performed by the admin, whom will usually set a remote in the local repository).
Inside local folder
git remote add origin firstname.lastname@example.org:/home/git/git/null.git #add origin remote git remote -v #view the existing remotes. Only origin remote was added origin email@example.com:/home/git/git/null.git (fetch) origin firstname.lastname@example.org:/home/git/git/null.git (push)
cloning the remote
To clone the remote git needs an authentication from its users, usually using ssh keys.
ssh key pairs (a public and private key) is an authentication method for clients to access servers through
ssh. E.g. For my computer to ssh to pzwart1.
How do we go about doing that:
- in our local computers we need to generate an ssh-key pair
- in our local computer a plain text file
~/.ssh/id_rsa.pubstores contains our public key
- we give our public key to the git admin,
- the adim adds the public key to the git server's
- we are ready to clone, push and pull to the remote.
git clone email@example.com:/home/git/git/amazing_project.git