This is an old revision of the document!
The git version control system is installed with the following command:
apt-get install git
git init #Initialize repository in actual working directory git config --global user.name "Your Name" #Set your account's default identity git config user.name "Your Name" #Set the identity only in this repository git status #Show which files tracked git add file #Add file "file" git add . #Add all files in working directory git commit -m "initial commit" #Commit all files with comment git log #Show history git reset --hard #Discard changes which are not commited yet git revert ID #Revert to change from ID - other changes after not affected git checkout ID file #Revert to change from ID git diff #Show diff/ changes
Every git user should first introduce himself to git, by running these two commands:
git config --global user.email "you@example.com" git config --global user.name "Your Name"
The above is already sufficient to use git in a distributed and secure way, provided users have access to the machine assuming the server role via SSH. On the server machine, creating a new repository can be done with:
git init --bare /path/to/repository
Note:This creates a bare repository, that cannot be used to edit files directly. If you would rather have a working copy of the contents of the repository on the server, ommit the –bare option.
Any client with SSH access to the machine can then clone the repository with:
git clone username@hostname:/path/to/repository
Once cloned to the client's machine, the client can edit files, then commit and share them with:
cd /path/to/repository #(edit some files git commit -a # Commit all changes to the local version of the repository git push origin master # Push changes to the server's version of the repository
eval $(ssh-agent -s) ssh-add /home/myuser/.ssh/id_rsa git remote add gitlab git@git.local:myuser/kubernetes.git #"gitlab" = name you can choose git remote add origin ssh://git@hostname:8822/tmade/icinga.git git remote #check, if remote location exists (test/ prod) git remote -v git add . #or "git add kubeadm-config.yaml" git commit -m "initial commit" #to the previously created project on e. g. gitlab git push gitlab master #gitlab target-server