=========== Git General =========== .. figure:: img/git-transport.png :align: center :width: 400px Git Tansport Links ===== * `Bitbucket `_ * `Github `_ * `Gitlab `_ * `Official Git Webpage `_ * `Tutorial Git Branching `_ Global setup ============ .. prompt:: bash git config --global user.name "username" git config --global user.email "your@email.com" Check setup ----------- .. prompt:: bash git config --list Save Credentials ---------------- .. prompt:: bash git config credential.helper store Not verify https Certificates ----------------------------- .. prompt:: bash git config --global http.sslVerify false Set commandline colors ---------------------- .. prompt:: bash git config color.status.added "green bold" git config color.status.changed "yellow bold" git config color.status.untracked "red bold" Set commandline editor ---------------------- .. prompt:: bash git config --global core.editor "nano -w" Git Repo Creation / Cloning =========================== Create new repo --------------------- .. prompt:: bash git init Status of repo -------------- .. prompt:: bash git status Settings of repo ---------------- .. prompt:: bash git remote -v Clone existing repo ------------------- .. prompt:: bash git clone git@gitlab.hevs.ch:course/ElN/eln_labs.git cd eln_labs touch README.md git add README.md git commit -m "add README" git push -u origin master Revert to last commit state --------------------------- go back to last committed servers state (can't be undone) .. prompt:: bash git reset --hard Existing folder --------------- .. prompt:: bash cd existing_folder git init git remote add origin git@gitlab.hevs.ch:course/ElN/eln_labs.git git add . git commit -m "Initial commit" git push -u origin master Switch to new Remote -------------------- .. prompt:: bash cd existing_repo git remote rename origin old-origin git remote add origin git@gitlab.hevs.ch:course/ElN/eln_labs.git git push -u origin --all git push -u origin --tags Get Remote Information ---------------------- .. prompt:: bash git remote show origin Change Push Remote URL ---------------------- .. prompt:: bash git remote set-url --push Git Repo information ==================== .. code-block:: bash # Status about current files ion folder $ git status # Status about last commits $ git log --oneline Add Files ========= .. code-block:: bash # Stage a File $ git add README.md # Commit file $ git commit –m "Initial commit, add README file" Checkout ======== .. code-block:: bash # Checkout certain commit $ git checkout e006db0 -b inspectingPrev # Checkout given branch $ git chekout master Push ==== .. prompt:: bash git push origin master Branch ====== .. code-block:: bash # Create new branch $ git branch dev_branch_1 # List all existing branches $ git branch # Checkout certain branch $ git branch dev_branch_1 # Delete certain branch $ git branch -d dev_branch_1 Merge ----- .. code-block:: bash # Checkout branch you want to merge into $ git checkout master # Merge the two branches $ git merge dev_branch_1 :tag:`Git`