"Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."
otherwise: use package manager (for example on Ubuntu)
sudo apt-get install gitassociate yourself with your work:
user name:
git config --global user.name "cgroll"email address:
git config --global user.email "groll.christian.edu@gmail.com"Files basically can be in one of the following states:
gitignoreControlled by git:
modified files:
overview command:
git statusfiles and changes need to be added to git:
git add someFile.txtgit add adds new files or changes to staging areausing git for backup, synchronization or cooperation:
a number of git hosting platforms:
Copying an existing repository from github:
https:
git clone https://github.com/cgroll/research_tools.gitssh:
git clone git@github.com:cgroll/research_tools.gitgit clone the original repository automatically gets the name origingit forgets nothing:
master branch by defaultgit:
git addgit commitas all merges must occur locally, possible changes on the remote need to be merged first
git pull origin masterdeal with merge conflicts: edit files
file content without merge problems.
<<<<<<<
this is the local version of the file content.
|||||||
this is the version of the common ancestor.
=======
this is the version of the remote commit.
>>>>>>>commit final version of files as they were edited
git add mergeFile1.txt
git add mergeFile2.csv
git commit -m "merge conflicts manually resolved"push final local version to remote repository
git push origin masterpull is shortcut for two separate steps:
git fetch: download contentgit merge: join different versionsif you need to update your repo from a remote, and do not want to commit temporary modifications:
git stash
git pull origin master
git stash applygit initgit commit -m "project started"add remote
git remote add upstream https://github.com/user/gitRepo.git⇒ messing with history could make some commits useless
temporarily recreate old state of repo
git checkout 4d3d2fd32recreating old state with editing enabled: create new branch at old repo state
git checkout -b testingBranch 4d3d2fd32⇒ modifications in testingBranch can be merged back into master
delete everything up to some state in the past
git reset --hard 4d3d2fd32Be careful:
If other people did build some changes on your history, you might delete some old commits that are required by their work.
⇒ Never mess with publicly available history in order to not break existing commit sequences.
if experiment fails: discard modifications by checking out the latest committed file version
git checkout filename.txt