Null/Git: Difference between revisions
(→clone) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[File:GitForArtists.jpg]] | |||
=resources= | =resources= | ||
[http://ndpsoftware.com/git-cheatsheet.html#loc=index; Git Cheatsheet] | [http://ndpsoftware.com/git-cheatsheet.html#loc=index; Git Cheatsheet] | ||
Line 106: | Line 108: | ||
How do we go about doing that: | How do we go about doing that: | ||
* in our local computers we need to [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key | * in our local computers we need to [https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key generate an ssh-key pair] | ||
* in our local computer a plain text file <code>~/.ssh/id_rsa.pub</code> stores contains our ''public key'' | * in our local computer a plain text file <code>~/.ssh/id_rsa.pub</code> stores contains our ''public key'' | ||
* we give our public key to the git admin, | * we give our public key to the git admin, |
Latest revision as of 12:33, 18 February 2016
resources
blog on Github Terms of Services
What is Git?
Git is frequently described as a distributed version control system. Initially create by the Linux' father Linus Torvalds in 2005 to facilitate code contributions to the Linux kernel.
version control system
A system for keeping track of the versions from a file e.g. drawing.svg, drawing.svg.v1, drawing.svg.v2, drawing.svg.v3
, while hiding all previous versions.
distributed Files from one project are mirror in multiple (collaborators') computers. Collaborators meaning they can sync their efforts by sending and receiving contribution.
version control
Simply version control an image, locally.
mkdir null-local
cd null-local
create a couple of SVG images and save it in project-dir.
Including in an SVG (code) the tag <image xlink:href="other.svg" />
you can include the other.svg image in current SVG
You need xmlns:xlink="http://www.w3.org/1999/xlink"
inside the svg tag e.g.:
<svg width="5cm" height="3cm" viewBox="0 0 5 3" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
git init
git add myimage.svg
git status
git commit -m "I am starting to version"
git log
git init
initiates a git repository. Creating a.git/
folder where all the Git information will be contained.git add
when run for the 1st time on file or dir, starts tracking it. (There might be project files you might not want to track).git status
display untracked and tracked (staged and unstaged for commit)git commit
creates a version or commit of your project. Usually accompanied by a message describing what happen in that commit.git log
show the history of commits, where each commit is shows an author, date, message and hash
git add
on a file that is being tracked and has been changed, "stage those changes"
undoing thing / going back
discard changes before committing
git reset HEAD <file>
for a 'staged' filegit reset HEAD <file>
for a 'unstaged' file
temporarily checkout past commits
git checkout --detach commit#
temporarily detaches the HEAD in order Look how things were in previous commits. "You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout".
To return the HEAD to the latest commit do git checkout master
(if the branch you are working in is a master (the default))
permanently reset to past commits
EXTREME!
git reset --hard commit#
- resets current HEAD to the specified commit.
Because of flag --hard
files in your repository will be removed if they exist prior to the commit.
remote repositories
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 /home/git/
With the repositories stored /home/git/git/
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 null-local/
dir:
git remote add origin git@pzwart1.wdka.hro.nl:/home/git/git/null.git #add origin remote
git remote -v #view the existing remotes. Only origin remote was added
origin git@pzwart1.wdka.hro.nl:/home/git/git/null.git (fetch)
origin git@pzwart1.wdka.hro.nl:/home/git/git/null.git (push)
cloning the remote
To clone the remote git needs an authentication from its users, usually using ssh keys.
authentication
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.pub
stores contains our public key - we give our public key to the git admin,
- the adim adds the public key to the git server's
/home/git/.ssh/authorized_keys
- we are ready to clone, push and pull to the remote.
clone
git clone git@pzwart1.wdka.hro.nl:/home/git/git/amazing_project.git