To show log messages of the changes between branches:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git log origin/master ^master
git log origin/master ^master
git log origin/master ^master
Show log graph
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git log --pretty=format:"
<h4 class="wp-block-heading" id="to-show-differences-between-branches"><span id="To_show_differences_between_branches">To show differences between branches:</span></h4>
<h3 class="wp-block-heading" id="show-location-of-configuration-files"><span id="Show_location_of_configuration_files">Show location of configuration files</span></h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --list --show-origin</pre><p>This dows not work, if you have set the environment var GIT_CONFIG. Inthis case, do</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
git config --global --list</pre><h2 class="wp-block-heading" id="edit-config-files"><span id="Edit_config_files">Edit config files</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --global</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --system</pre><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Configure the author name to be used with your commits.</td><td><code>git config --global user.name"XXX"</code></td></tr><tr><td>Configure the author email address to be used with your commits</td><td><code>git config --global user.email xxx@example.com</code></td></tr><tr><td>Will remove user credential details from the repository</td><td><code>git config --local credential.helper""</code></td></tr><tr><td></td><td>git config —show-origin</td></tr><tr><td>List all currently configured remote repository URLs</td><td><code>git remote -v</code></td></tr><tr><td>If you haven’t connected your local repository to a remote server, To add a remote server to a local repository</td><td><code>git remote add origin <repo_url></code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-commit-and-push"><span id="Git_Commit_and_Push">Git Commit and Push</span></h2><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Create a file name <code>README.md</code> with <code>Readme content</code> content</td><td><code>echo "Readme content">> README.md</code></td></tr><tr><td>List the files you’ve changed and those you still need to add or commit</td><td><code>git status</code></td></tr><tr><td>Add all or one file to staging</td><td><code>git add .</code> OR <code>git add file_name</code></td></tr><tr><td>Commit changes to head with message</td><td><code>git commit -m 'message'</code></td></tr><tr><td>Commit any files you’ve added with <code>git add</code>, and also commit any files you’ve changed since then</td><td><code>git commit -a</code></td></tr><tr><td>Send all commits from local repository to remote repository</td><td><code>git push</code></td></tr><tr><td>Do a <code>git push</code> and sets the default remote branch for the current local branch. So any future <code>git pull</code> command will attempt to bring in commits from the <code><remote-branch></code>into the current local branch</td><td><code>git push -u <remote-branch></code></td></tr><tr><td>Send changes to the master branch of your remote repository</td><td><code>git push origin master</code></td></tr><tr><td>Push a specific branch to your remote repository</td><td><code>git push origin <branch_name></code></td></tr><tr><td>Push all branches to your remote repository</td><td><code>git push --all origin</code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="working-with-the-git-workflow"><span id="Working_with_the_Git_Workflow">Working with the Git Workflow</span></h2><p>The following steps are based on a branching model, described <a href="https://nvie.com/posts/a-successful-git-branching-model/">here</a>.</p><figure class="wp-block-table"><table><tbody><tr><th>Name</th><th> Beschreibung</th></tr><tr><td>master</td><td></td></tr><tr><td>hotfixes</td></tr><tr><td>release</td></tr><tr><td>develop</td></tr><tr><td>feature</td></tr></tbody></table></figure><h3 class="wp-block-heading" id="Workflow-MitBranchesarbeiten"><span id="Working_with_branches">Working with branches</span></h3><h4 class="wp-block-heading" id="Workflow-Brancheserstellen"><span id="Create_branch_8216develop8217">Create branch ‘develop’</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone git@github.com:<USER>/<REPO>.git develop
$ cd develop
$ git checkout -b develop
$ git push --set-upstream origin develop</pre><h4 class="wp-block-heading" id="create-branch-feature-xxx"><span id="Create_branch_8216feature-xxx8217">Create branch ‘feature-xxx’</span></h4><p>We dont’t want do clone the whole repository, but only the files needed for the feature</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone -b develop -n --depth 1 git@github.com:<USER>/<REPO>.git feature-2.2.0
$ cd feature-2.2.0
</pre><h4 class="wp-block-heading" id="Workflow-Branchlöschen"><span id="Branch_loschen">Branch löschen</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git push origin -delete hotfix-1.2.1-compress-data</pre><h3 class="wp-block-heading" id="Workflow-Workflow-Cheatsheet"><span id="Workflow_8211_Cheatsheet">Workflow – Cheatsheet</span></h3><h4 class="wp-block-heading" id="working-with-branches"><span id="Working_with_branches-2">Working with branches</span></h4><p><strong>How to rename git local and remote branches</strong></p><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Check out branch with old name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git checkout feature-2.1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Rename branch</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m feature-2.01.02</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Checkin branch with new name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :feature-2.1.2 feature-2.01.02</pre></div></div><p><strong>1. Rename your local branch.</strong></p><p>If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.</p><p>If you are on the branch you want to rename:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m new-name</pre><p>If you are on a different branch:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old-name new-name</pre><p><strong>2. Delete the old-name remote branch and push the new-name local branch.</strong></p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :old-name new-name</pre><p><strong>3. Reset the upstream branch for the new-name local branch.</strong>Switch to the branch and then:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin -u new-name</pre><p>Or you as a fast way to do that, you can use these 3 steps: command in your terminal</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete old branch
git push --set-upstream origin new_branch # Push new branch, set local branch to track new remote</pre><figure class="wp-block-table"><table><tbody><tr><th>Neues Feature erstellen</th></tr><tr><td>Repository clonen</td><td>gitcheckout−bfeature−1.2.2develop</td></tr><tr><td>Änderungendurchführen</td></tr><tr><td>Änderungeneinchecken</td><td> git checkout develop<br>gitmerge–no−fffeature−1.2.2<br> git branch -d feature-1.2.2 <br>gitpushorigindevelop</td></tr><tr></tr></tbody></table></figure><figureclass="wp−block−table"><table><tbody><tr><th>NeuenHotfixerstelllen</th></tr><tr><td>Repositoryauschecken</td><td> git checkout -b hotfix-1.2.1 master</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>gitcommit−a−m“hotfix:hotfix−1.2.1|compressmart”</td></tr><tr><td>Hotfixbeenden</td><td> git checkout master<br>gitmerge–no−ffhotfix−1.2.1<br> git tag -a 1.2.1</td></tr><tr><td>Hotfix in Master einchecken</td><td>gitcheckoutdevelop<br> git merge –no-ff hotfix-1.2.1 </td></tr><tr><td>Hotfix Branch entfernen</td><td>gitbranch−dhotfix−1.2.1</td></tr><tr></tr></tbody></table></figure><figureclass="wp−block−table"><table><tbody><tr><th>NeuesReleaseerstellen:</th></tr><tr><td>Repositoryclonen</td><td> git checkout -b release-1.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>gitcommit−a−m“release:changesforrelease1.2”</td></tr><tr><td>Releasebeenden</td><td> git checkout master<br>gitmerge–no−ffrelease−1.2<br> git tag -a 1.2</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-flow"><span id="Git_Flow">Git Flow</span></h2><h4 class="wp-block-heading" id="initialize"><span id="Initialize">Initialize</span></h4><p>Start using git-flow by initializing it inside an existing git repository:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow init</pre><h4 class="wp-block-heading" id="start-a-new-feature"><span id="Start_a_new_feature">Start a new feature</span></h4><p>Development of new features starting from the ‘develop’ branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature start MYFEATURE</pre><h4 class="wp-block-heading" id="finish-up-a-feature"><span id="Finish_up_a_feature">Finish up a feature</span></h4><p>Finish the development of a feature. This action performs the following</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature finish MYFEATURE</pre><h4 class="wp-block-heading" id="publish-a-feature"><span id="Publish_a_feature">Publish a feature</span></h4><p>Publish a feature to the remote server so it can be used by other users.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature publish MYFEATURE</pre><h3 class="wp-block-heading" id="getting-a-published-feature"><span id="Getting_a_published_feature">Getting a published feature</span></h3><p>Get a feature published by another user.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature pull origin MYFEATURE</pre><p>You can track a feature on origin by using</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature track MYFEATURE</pre><h4 class="wp-block-heading" id="start-a-release"><span id="Start_a_release">Start a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release start RELEASE [BASE]</pre><p>It’s wise to publish the release branch after creating it to allow release commits by other developers. Do it similar to feature publishing with the command:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release publish RELEASE</pre><p>(You can track a remote release with the <br><code>git flow release track RELEASE</code>command)</p><h4 class="wp-block-heading" id="finish-up-a-release"><span id="Finish_up_a_release">Finish up a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release finish RELEASE</pre><p>Don’t forget to push your tags with <code>git push origin --tags</code></p><h4 class="wp-block-heading" id="hotfixes"><span id="Hotfixes">Hotfixes</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix start VERSION [BASENAME]</pre><h4 class="wp-block-heading" id="finish-a-hotfix"><span id="Finish_a_hotfix">Finish a hotfix</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix finish VERSION</pre><h2 class="wp-block-heading" id="usefull-commands"><span id="Usefull_commands">Usefull commands</span></h2><figure class="wp-block-table"><table><tbody><tr><th>basic commands</th><th>description</th></tr><tr><td>git init</td></tr><tr><td>git status [ -s ]</td><td>status of files and local repo</td></tr><tr><td>git ls-files</td><td>show files which are tracked by git</td></tr><tr><td>git log [ –oneline ]<br>git log [–oneline –graph –decorate –all]</td><td>shows commit history</td></tr><tr><td>git add <changed file><br>git add .git add -u</td><td>add single file to indexadd all files from the workspace to indexstage current workspace into index to cleanup inconsistencies</td></tr><tr><td>git commit [ -m ‘message’ ]</td><td>commit into local repo only</td></tr><tr><td>git push -u origin master</td><td>push the repo from local to remote repo</td></tr><tr><td>git help [option]</td><td>get help page for specific options</td></tr><tr><td>git config –global alias.bla “command”<br>git bla [– <filename>]</td><td>set alias bla to a specific commandexec alias (for specific file)</td></tr><tr><td>git mv fileA fileB<br>git commit -m “…..”</td><td>rename fileA to fileBand commit</td></tr><tr><td>git rm fileC<br>git commit -m “…..”</td><td>delete fileCand commit</td></tr><tr></tr><tr><th>advanced commands</th><th>description</th></tr><tr><td>git reset HEAD <filename></td><td>undo changes from index back to workspace</td></tr><tr><td>git checkout <filename><br>git checkout master<br>git checkout <branchname></td><td>checkout single file from local repo to workspacecheckout/switch to the master branchcheckout/switch to another branch</td></tr><tr><td>git checkout -b <new branchname><br>git branch <new branchname></td><td>create new branch and switch to it immediatelycreate new branch in the background, doesn’t switch to it</td></tr><tr><td>git branch</td><td>shows all available branches</td></tr><tr><td>git diff<br>git difftool</td><td>show differences of local and committed file<br>shows diff in vimdiff</td></tr><tr><td>git merge <other branch><br>git mergetool</td><td>merge other branch into master (current branch)manage the different files in vimdiff</td></tr><tr><td>git branch -d <branchname></td><td>delete branch (does NOT include merge)</td></tr><tr><td>git branch -m <new name></td><td>rename a</td></tr><tr><td> git diff master..development</td><td>compare two branches</td></tr><tr><td>git tag <mytag><br>git tag -a v1.0 -m “description”<br>git show v1.0</td><td>add an additional label/tag to a branchannotation tag with release informationshows details of tag v1.0</td></tr><tr><td>git stash</td></tr><tr><td>git reset <ID> [–soft | –mixed | –hard]<br>git reflog ….</td></tr><tr><td>git fetch ….</td><td>update local repo with changes from remote repo. (non destructive)</td></tr><tr><td>git pull …</td><td>update local repo with changes from remote repo. it does effectively a fetch and merge in one command</td></tr><tr><td>git clone https://<<em>username</em>>:<<em>token</em>>@github.com/<<em>organisation-space</em>>/<<em>repository</em>><br></td><td>download the remote repo into local workspace</td></tr><tr><td>git remote -v<br>git remote show origin</td><td>shows url of remote reposhows detail infos of a remote repo</td></tr><tr></tr><tr><td>.gitignore</td><td>contains filename to exclude from git</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-workflow"><span id="Git_Workflow">Git Workflow</span></h2><h3 class="wp-block-heading" id="release"><span id="Release">Release</span></h3><h4 class="wp-block-heading" id="creating-a-release-branch"><span id="Creating_a_release_branch">Creating a release branch</span></h4><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code>is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckout−brelease−1.2develop</pre></div></div><divclass="wp−block−columnshas−2−columnsis−layout−flexwp−container−core−columns−is−layout−7wp−block−columns−is−layout−flex"><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><p>Aftercreatinganewbranchandswitchingtoit,webumptheversionnumber.Here,<code>bump−version.sh</code>isafictionalshellscriptthatchangessomefilesintheworkingcopytoreflectthenewversion.(Thiscanofcoursebeamanualchange—thepointbeingthat<em>some</em>fileschange.)Then,thebumpedversionnumberiscommitted.</p><p>Thisnewbranchmayexistthereforawhile,untilthereleasemayberolledoutdefinitely.Duringthattime,bugfixesmaybeappliedinthisbranch(ratherthanonthe<code>develop</code>branch).Addinglargenewfeatureshereisstrictlyprohibited.Theymustbemergedinto<code>develop</code>,andtherefore,waitforthenextbigrelease.</p></div><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> ./bump-version.sh 1.2<br>
$ git branch -d release-1.2</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-8 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>When the state of the release branch is ready to become a real release, some actions need to be carried out.</p><p>First, the release branch is merged into <code>master</code>(since every commit on <code>master</code> is a new release <em>by definition</em>, remember).</p><p>Next, that commit on <code>master</code> must be tagged for easy future reference to this historical version.</p><p>Finally, the changes made on the release branch need to be merged back into <code>develop</code>, so that future releases also contain these bug fixes.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>The release is now done, and tagged for future reference.</p><p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop
$ git merge --no-ff release-1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>This step may well lead to a merge conflict(probably even, since we have changed the version number). If so, fix it and commit.</p><p>Now we are really done and the release branch may be removed, since we don’t need it anymore:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git branch -d release-1.2</pre></div></div><h3 class="wp-block-heading" id="feature"><span id="Feature">Feature</span></h3><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/fb@2x-e1554287024987-700x261.png" alt=""class="wp-image-4387 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
$ .. do changes...
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><h4 class="wp-block-heading" id="creating-a-feature-branch"><span id="Creating_a_feature_branchnbsp">Creating a feature branch </span></h4><p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
Switched to a new branch "myfeature"
</pre><h4 class="wp-block-heading" id="incorporating-a-finished-feature-on-develop"><span id="Incorporating_a_finished_feature_on_developnbsp">Incorporating a finished feature on develop </span></h4><p>Finished features may be merged into the <code>develop</code> branch to definitely add them to the upcoming release:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop<
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop </pre></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-12 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.</p><p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature(i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the <code>--no-ff</code> flag was used.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><figure class="wp-block-image"><img class="lazy" decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="https://nvie.com/img/merge-without-ff@2x.png" alt=""></figure></div></div><h2 class="wp-block-heading" id="hotfix"><span id="Hotfix">Hotfix</span></h2><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/hotfix-branches@2x-e1554287153961-700x519.png" alt=""class="wp-image-4394 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b hotfix-1.2.1 master
export GIT_CURL_VERBOSE=1</pre><h4 class="wp-block-heading" id="error-message-your-local-changes-to-the-following-files-would-be-overwritten-by-merge"><span id="Error_Message_Your_local_changes_to_the_following_files_would_be_overwritten_by_merge">Error Message: Your local changes to the following files would be overwritten by merge: </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.</pre><h4 class="wp-block-heading" id="solution"><span id="Solution">Solution:</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git fetch origin master
$ gt commit -m "change: in file [local-path]"</pre><h4 class="wp-block-heading" id="fatal-sha1-file-stdout-write-error-broken-pipe"><span id="fatal_sha1_file_8216ltstdoutgt8217_write_error_Broken_Pipe">fatal: sha1 file ‘<stdout>’ write error: Broken Pipe </span></h4><p>When using ssh to connect to the repositoriy, sometime, you got a timeout if you push to many files or if the files are to big</p><h4 class="wp-block-heading" id="one-possible-solution"><span id="One_possible_Solution">One possible Solution</span></h4><p>Configure ssh to use the following value</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">~/.ssh/config</pre><pre class="EnlighterJSRAW" data-enlighter-language="ini" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Host *
ServerAliveInterval 30
ServerAliveCountMax 4</pre><h4 class="wp-block-heading" id="git-clone-file-name-to-long-on-windows"><span id="git_clone_file_name_to_long_on_windows">git clone: file name to long on windows</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --system core.longpathstrue</pre><h4 class="wp-block-heading" id="git-config-global-user-email-some-email-com-throws-error-only-one-config-file-at-a-time"><span id="git_config_8211global_useremail_someemailcom_throws_error_only_one_config_file_at_a_time">git config –global user.email “some@email.com” throws “error: only one config file at a time.</span></h4><p>Try to unset GIT_CONFIG and then list your global config with</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
-rw-r--r-- 1 user wheel 019 Mär 18:48 README.md</pre><p>You will notice, that the file README.md is empty. Because it was ony created with touch.</p><h4 class="wp-block-heading" id="add-some-content-to-source-repository"><span id="Add_some_content_to_source_repository">Add some content to source repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">cdHOME/entw/src
$ echo "# This is the README.md from ENTW">README.md
git log --pretty=format:"
<h4 class="wp-block-heading" id="to-show-differences-between-branches"><span id="To_show_differences_between_branches">To show differences between branches:</span></h4>
<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitdiffmasterorigin/master</pre><h4class="wp−block−heading"id="show−what−git−pull−will−doing"><spanid="Showwhatgitpullwilldoing">Show,whatgitpullwilldoing</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git fetch && git diff HEAD..@{u}</pre><p>Or add the command to ~/.gitconfig file:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">[alias]
diffpull=!git fetch && git diff HEAD..@{u}</pre><h4 class="wp-block-heading" id="run-this-to-see-how-git-diff-resolution-works"><span id="Run_this_to_see_how_git_diff_resolution_works">Run this to see how git diff resolution works</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git rev-parse origin</pre><h4 class="wp-block-heading" id="delete-remote-branch"><span id="Delete_remote_branch">Delete remote branch</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git clone <repository> master
cd master
git push origin --delete feature-2.01.03</pre><h4 class="wp-block-heading" id="show-log"><span id="Show_log">Show log</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git log --oneline --graph --all --decorate</pre><h4 class="wp-block-heading" id="undo-commit"><span id="Undo_commit">Undo commit</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git commit --amend</pre><h4 class="wp-block-heading" id="unstaging-a-staged-file"><span id="Unstaging_a_staged_file">Unstaging a staged file</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git reset HEAD <filename></pre><h4 class="wp-block-heading" id="unmodifying-a-modified-file"><span id="Unmodifying_a_Modified_File">Unmodifying a Modified File</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckout−−<filename></pre><h4class="wp−block−heading"id="retrieve−last−modification−date"><spanid="Retrievelastmodificationdate">Retrievelastmodificationdate</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="shell"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers="false"data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">gitls−files−z|xargs−0−n1−I−−gitlog−1−−format="<h2class="wp−block−heading"id="git−configuration"><spanid="GitConfiguration">GitConfiguration</span></h2><h3class="wp−block−heading"id="show−location−of−configuration−files"><spanid="Showlocationofconfigurationfiles">Showlocationofconfigurationfiles</span></h3><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">gitconfig−−list−−show−origin</pre><p>Thisdowsnotwork,ifyouhavesettheenvironmentvarGITCONFIG.Inthiscase,do</p><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">unsetGITCONFIGgitconfig−−global−−list</pre><h2class="wp−block−heading"id="edit−config−files"><spanid="Editconfigfiles">Editconfigfiles</span></h2><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">gitconfig−−edit−−global</pre><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">gitconfig−−edit−−system</pre><figureclass="wp−block−table"><table><thead><tr><th>DESCRIPTION</th><th>GITCOMMAND</th></tr></thead><tbody><tr><td>Configuretheauthornametobeusedwithyourcommits.</td><td><code>gitconfig−−globaluser.name"XXX"</code></td></tr><tr><td>Configuretheauthoremailaddresstobeusedwithyourcommits</td><td><code>gitconfig−−globaluser.emailxxx@example.com</code></td></tr><tr><td>Willremoveusercredentialdetailsfromtherepository</td><td><code>gitconfig−−localcredential.helper""</code></td></tr><tr><td></td><td>gitconfig—show−origin</td></tr><tr><td>ListallcurrentlyconfiguredremoterepositoryURLs</td><td><code>gitremote−v</code></td></tr><tr><td>Ifyouhaven′tconnectedyourlocalrepositorytoaremoteserver,Toaddaremoteservertoalocalrepository</td><td><code>gitremoteaddorigin<repourl></code></td></tr></tbody></table></figure><h2class="wp−block−heading"id="git−commit−and−push"><spanid="GitCommitandPush">GitCommitandPush</span></h2><figureclass="wp−block−table"><table><thead><tr><th>DESCRIPTION</th><th>GITCOMMAND</th></tr></thead><tbody><tr><td>Createafilename<code>README.md</code>with<code>Readmecontent</code>content</td><td><code>echo"Readmecontent">>README.md</code></td></tr><tr><td>Listthefilesyou′vechangedandthoseyoustillneedtoaddorcommit</td><td><code>gitstatus</code></td></tr><tr><td>Addalloronefiletostaging</td><td><code>gitadd.</code>OR<code>gitaddfilename</code></td></tr><tr><td>Commitchangestoheadwithmessage</td><td><code>gitcommit−m′message′</code></td></tr><tr><td>Commitanyfilesyou′veaddedwith<code>gitadd</code>,andalsocommitanyfilesyou′vechangedsincethen</td><td><code>gitcommit−a</code></td></tr><tr><td>Sendallcommitsfromlocalrepositorytoremoterepository</td><td><code>gitpush</code></td></tr><tr><td>Doa<code>gitpush</code>andsetsthedefaultremotebranchforthecurrentlocalbranch.Soanyfuture<code>gitpull</code>commandwillattempttobringincommitsfromthe<code><remote−branch></code>intothecurrentlocalbranch</td><td><code>gitpush−u<remote−branch></code></td></tr><tr><td>Sendchangestothemasterbranchofyourremoterepository</td><td><code>gitpushoriginmaster</code></td></tr><tr><td>Pushaspecificbranchtoyourremoterepository</td><td><code>gitpushorigin<branchname></code></td></tr><tr><td>Pushallbranchestoyourremoterepository</td><td><code>gitpush−−allorigin</code></td></tr></tbody></table></figure><h2class="wp−block−heading"id="working−with−the−git−workflow"><spanid="WorkingwiththeGitWorkflow">WorkingwiththeGitWorkflow</span></h2><p>Thefollowingstepsarebasedonabranchingmodel,described<ahref="https://nvie.com/posts/a−successful−git−branching−model/">here</a>.</p><figureclass="wp−block−table"><table><tbody><tr><th>Name</th><th>Beschreibung</th></tr><tr><td>master</td><td></td></tr><tr><td>hotfixes</td></tr><tr><td>release</td></tr><tr><td>develop</td></tr><tr><td>feature</td></tr></tbody></table></figure><h3class="wp−block−heading"id="Workflow−MitBranchesarbeiten"><spanid="Workingwithbranches">Workingwithbranches</span></h3><h4class="wp−block−heading"id="Workflow−Brancheserstellen"><spanid="Createbranch8216develop8217">Createbranch‘develop′</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="shell"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git clone git@github.com:<USER>/<REPO>.git develop
cddevelop git checkout -b develop
gitpush−−set−upstreamorigindevelop</pre><h4class="wp−block−heading"id="create−branch−feature−xxx"><spanid="Createbranch8216feature−xxx8217">Createbranch‘feature−xxx′</span></h4><p>Wedont′twantdoclonethewholerepository,butonlythefilesneededforthefeature</p><preclass="EnlighterJSRAW"data−enlighter−language="shell"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git clone -b develop -n --depth 1 git@github.com:<USER>/<REPO>.git feature-2.2.0
cdfeature−2.2.0</pre><h4class="wp−block−heading"id="Workflow−Branchlöschen"><spanid="Branchloschen">Branchlöschen</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="shell"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git push origin -delete hotfix-1.2.1-compress-data</pre><h3 class="wp-block-heading" id="Workflow-Workflow-Cheatsheet"><span id="Workflow_8211_Cheatsheet">Workflow – Cheatsheet</span></h3><h4 class="wp-block-heading" id="working-with-branches"><span id="Working_with_branches-2">Working with branches</span></h4><p><strong>How to rename git local and remote branches</strong></p><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Check out branch with old name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git checkout feature-2.1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Rename branch</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m feature-2.01.02</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Checkin branch with new name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :feature-2.1.2 feature-2.01.02</pre></div></div><p><strong>1. Rename your local branch.</strong></p><p>If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.</p><p>If you are on the branch you want to rename:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m new-name</pre><p>If you are on a different branch:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old-name new-name</pre><p><strong>2. Delete the old-name remote branch and push the new-name local branch.</strong></p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :old-name new-name</pre><p><strong>3. Reset the upstream branch for the new-name local branch.</strong>Switch to the branch and then:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin -u new-name</pre><p>Or you as a fast way to do that, you can use these 3 steps: command in your terminal</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete old branch
git push --set-upstream origin new_branch # Push new branch, set local branch to track new remote</pre><figure class="wp-block-table"><table><tbody><tr><th>Neues Feature erstellen</th></tr><tr><td>Repository clonen</td><td>gitcheckout−bfeature−1.2.2develop</td></tr><tr><td>Änderungendurchführen</td></tr><tr><td>Änderungeneinchecken</td><td> git checkout develop<br>gitmerge–no−fffeature−1.2.2<br> git branch -d feature-1.2.2 <br>gitpushorigindevelop</td></tr><tr></tr></tbody></table></figure><figureclass="wp−block−table"><table><tbody><tr><th>NeuenHotfixerstelllen</th></tr><tr><td>Repositoryauschecken</td><td> git checkout -b hotfix-1.2.1 master</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>gitcommit−a−m“hotfix:hotfix−1.2.1|compressmart”</td></tr><tr><td>Hotfixbeenden</td><td> git checkout master<br>gitmerge–no−ffhotfix−1.2.1<br> git tag -a 1.2.1</td></tr><tr><td>Hotfix in Master einchecken</td><td>gitcheckoutdevelop<br> git merge –no-ff hotfix-1.2.1 </td></tr><tr><td>Hotfix Branch entfernen</td><td>gitbranch−dhotfix−1.2.1</td></tr><tr></tr></tbody></table></figure><figureclass="wp−block−table"><table><tbody><tr><th>NeuesReleaseerstellen:</th></tr><tr><td>Repositoryclonen</td><td> git checkout -b release-1.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>gitcommit−a−m“release:changesforrelease1.2”</td></tr><tr><td>Releasebeenden</td><td> git checkout master<br>gitmerge–no−ffrelease−1.2<br> git tag -a 1.2</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-flow"><span id="Git_Flow">Git Flow</span></h2><h4 class="wp-block-heading" id="initialize"><span id="Initialize">Initialize</span></h4><p>Start using git-flow by initializing it inside an existing git repository:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow init</pre><h4 class="wp-block-heading" id="start-a-new-feature"><span id="Start_a_new_feature">Start a new feature</span></h4><p>Development of new features starting from the ‘develop’ branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature start MYFEATURE</pre><h4 class="wp-block-heading" id="finish-up-a-feature"><span id="Finish_up_a_feature">Finish up a feature</span></h4><p>Finish the development of a feature. This action performs the following</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature finish MYFEATURE</pre><h4 class="wp-block-heading" id="publish-a-feature"><span id="Publish_a_feature">Publish a feature</span></h4><p>Publish a feature to the remote server so it can be used by other users.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature publish MYFEATURE</pre><h3 class="wp-block-heading" id="getting-a-published-feature"><span id="Getting_a_published_feature">Getting a published feature</span></h3><p>Get a feature published by another user.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature pull origin MYFEATURE</pre><p>You can track a feature on origin by using</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature track MYFEATURE</pre><h4 class="wp-block-heading" id="start-a-release"><span id="Start_a_release">Start a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release start RELEASE [BASE]</pre><p>It’s wise to publish the release branch after creating it to allow release commits by other developers. Do it similar to feature publishing with the command:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release publish RELEASE</pre><p>(You can track a remote release with the <br><code>git flow release track RELEASE</code>command)</p><h4 class="wp-block-heading" id="finish-up-a-release"><span id="Finish_up_a_release">Finish up a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release finish RELEASE</pre><p>Don’t forget to push your tags with <code>git push origin --tags</code></p><h4 class="wp-block-heading" id="hotfixes"><span id="Hotfixes">Hotfixes</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix start VERSION [BASENAME]</pre><h4 class="wp-block-heading" id="finish-a-hotfix"><span id="Finish_a_hotfix">Finish a hotfix</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix finish VERSION</pre><h2 class="wp-block-heading" id="usefull-commands"><span id="Usefull_commands">Usefull commands</span></h2><figure class="wp-block-table"><table><tbody><tr><th>basic commands</th><th>description</th></tr><tr><td>git init</td></tr><tr><td>git status [ -s ]</td><td>status of files and local repo</td></tr><tr><td>git ls-files</td><td>show files which are tracked by git</td></tr><tr><td>git log [ –oneline ]<br>git log [–oneline –graph –decorate –all]</td><td>shows commit history</td></tr><tr><td>git add <changed file><br>git add .git add -u</td><td>add single file to indexadd all files from the workspace to indexstage current workspace into index to cleanup inconsistencies</td></tr><tr><td>git commit [ -m ‘message’ ]</td><td>commit into local repo only</td></tr><tr><td>git push -u origin master</td><td>push the repo from local to remote repo</td></tr><tr><td>git help [option]</td><td>get help page for specific options</td></tr><tr><td>git config –global alias.bla “command”<br>git bla [– <filename>]</td><td>set alias bla to a specific commandexec alias (for specific file)</td></tr><tr><td>git mv fileA fileB<br>git commit -m “…..”</td><td>rename fileA to fileBand commit</td></tr><tr><td>git rm fileC<br>git commit -m “…..”</td><td>delete fileCand commit</td></tr><tr></tr><tr><th>advanced commands</th><th>description</th></tr><tr><td>git reset HEAD <filename></td><td>undo changes from index back to workspace</td></tr><tr><td>git checkout <filename><br>git checkout master<br>git checkout <branchname></td><td>checkout single file from local repo to workspacecheckout/switch to the master branchcheckout/switch to another branch</td></tr><tr><td>git checkout -b <new branchname><br>git branch <new branchname></td><td>create new branch and switch to it immediatelycreate new branch in the background, doesn’t switch to it</td></tr><tr><td>git branch</td><td>shows all available branches</td></tr><tr><td>git diff<br>git difftool</td><td>show differences of local and committed file<br>shows diff in vimdiff</td></tr><tr><td>git merge <other branch><br>git mergetool</td><td>merge other branch into master (current branch)manage the different files in vimdiff</td></tr><tr><td>git branch -d <branchname></td><td>delete branch (does NOT include merge)</td></tr><tr><td>git branch -m <new name></td><td>rename a</td></tr><tr><td> git diff master..development</td><td>compare two branches</td></tr><tr><td>git tag <mytag><br>git tag -a v1.0 -m “description”<br>git show v1.0</td><td>add an additional label/tag to a branchannotation tag with release informationshows details of tag v1.0</td></tr><tr><td>git stash</td></tr><tr><td>git reset <ID> [–soft | –mixed | –hard]<br>git reflog ….</td></tr><tr><td>git fetch ….</td><td>update local repo with changes from remote repo. (non destructive)</td></tr><tr><td>git pull …</td><td>update local repo with changes from remote repo. it does effectively a fetch and merge in one command</td></tr><tr><td>git clone https://<<em>username</em>>:<<em>token</em>>@github.com/<<em>organisation-space</em>>/<<em>repository</em>><br></td><td>download the remote repo into local workspace</td></tr><tr><td>git remote -v<br>git remote show origin</td><td>shows url of remote reposhows detail infos of a remote repo</td></tr><tr></tr><tr><td>.gitignore</td><td>contains filename to exclude from git</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-workflow"><span id="Git_Workflow">Git Workflow</span></h2><h3 class="wp-block-heading" id="release"><span id="Release">Release</span></h3><h4 class="wp-block-heading" id="creating-a-release-branch"><span id="Creating_a_release_branch">Creating a release branch</span></h4><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code>is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckout−brelease−1.2develop</pre></div></div><divclass="wp−block−columnshas−2−columnsis−layout−flexwp−container−core−columns−is−layout−7wp−block−columns−is−layout−flex"><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><p>Aftercreatinganewbranchandswitchingtoit,webumptheversionnumber.Here,<code>bump−version.sh</code>isafictionalshellscriptthatchangessomefilesintheworkingcopytoreflectthenewversion.(Thiscanofcoursebeamanualchange—thepointbeingthat<em>some</em>fileschange.)Then,thebumpedversionnumberiscommitted.</p><p>Thisnewbranchmayexistthereforawhile,untilthereleasemayberolledoutdefinitely.Duringthattime,bugfixesmaybeappliedinthisbranch(ratherthanonthe<code>develop</code>branch).Addinglargenewfeatureshereisstrictlyprohibited.Theymustbemergedinto<code>develop</code>,andtherefore,waitforthenextbigrelease.</p></div><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> ./bump-version.sh 1.2<br>
git commit -a -m "Version 1.2"</pre></div></div><h4 class="wp-block-heading" id="finishing-a-release-branch"><span id="Finishing_a_release_branchnbsp"> Finishing a release branch </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git checkout master
gitmerge−−no−ffrelease−1.2 git tag -a 1.2
gitcheckoutdevelop git merge --no-ff release-1.2
gitbranch−drelease−1.2</pre><divclass="wp−block−columnshas−2−columnsis−layout−flexwp−container−core−columns−is−layout−8wp−block−columns−is−layout−flex"><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><p>Whenthestateofthereleasebranchisreadytobecomearealrelease,someactionsneedtobecarriedout.</p><p>First,thereleasebranchismergedinto<code>master</code>(sinceeverycommiton<code>master</code>isanewrelease<em>bydefinition</em>,remember).</p><p>Next,thatcommiton<code>master</code>mustbetaggedforeasyfuturereferencetothishistoricalversion.</p><p>Finally,thechangesmadeonthereleasebranchneedtobemergedbackinto<code>develop</code>,sothatfuturereleasesalsocontainthesebugfixes.</p></div><divclass="wp−block−columnis−layout−flowwp−block−column−is−layout−flow"><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git checkout master
gitmerge−−no−ffrelease−1.2 git tag -a 1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>The release is now done, and tagged for future reference.</p><p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckoutdevelop git merge --no-ff release-1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.</p><p>Now we are really done and the release branch may be removed, since we don’t need it anymore:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitbranch−drelease−1.2</pre></div></div><h3class="wp−block−heading"id="feature"><spanid="Feature">Feature</span></h3><figureclass="wp−block−image"><imgdecoding="async"src="data:image/svg+xml, git checkout -b myfeature develop
..dochanges... git checkout develop
gitmerge−−no−ffmyfeature git branch -d myfeature
git push origin develop</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><h4 class="wp-block-heading" id="creating-a-feature-branch"><span id="Creating_a_feature_branchnbsp">Creating a feature branch </span></h4><p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git checkout -b myfeature develop
Switched to a new branch "myfeature"
</pre><h4 class="wp-block-heading" id="incorporating-a-finished-feature-on-develop"><span id="Incorporating_a_finished_feature_on_developnbsp">Incorporating a finished feature on develop </span></h4><p>Finished features may be merged into the <code>develop</code> branch to definitely add them to the upcoming release:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckoutdevelop< git merge --no-ff myfeature
gitbranch−dmyfeature git push origin develop </pre></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-12 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.</p><p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the <code>--no-ff</code> flag was used.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><figure class="wp-block-image"><img class="lazy" decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="https://nvie.com/img/merge-without-ff@2x.png" alt=""></figure></div></div><h2 class="wp-block-heading" id="hotfix"><span id="Hotfix">Hotfix</span></h2><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/hotfix-branches@2x-e1554287153961-700x519.png" alt="" class="wp-image-4394 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gitcheckout−bhotfix−1.2.1master ... do changes ...
gitcommit−a−m"HotfixVersion1.2.1" .. fix bug
gitcommit−m"Fixedsevereproductionproblem" git checkout master
gitmerge−−no−ffhotfix−1.2.1 git tag -a 1.2.1
# incude hotfix into develop
gitcheckoutdevelop git merge --no-ff hotfix-1.2.1
# finally, remove hotfix branch
gitbranch−dhotfix−1.2.1</pre><h2class="wp−block−heading"id="troubleshooting"><spanid="Troubleshooting">Troubleshooting</span></h2><h4class="wp−block−heading"id="debugging−github−errors"><spanid="DebuggingGithubErrors">DebuggingGithubErrors</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">exportGITTRACEPACKET=1exportGITTRACE=1exportGITCURLVERBOSE=1</pre><h4class="wp−block−heading"id="error−message−your−local−changes−to−the−following−files−would−be−overwritten−by−merge"><spanid="ErrorMessageYourlocalchangestothefollowingfileswouldbeoverwrittenbymerge">ErrorMessage:Yourlocalchangestothefollowingfileswouldbeoverwrittenbymerge:</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group="">error:Yourlocalchangestothefollowingfileswouldbeoverwrittenbymerge:<br>README.md<br>Pleasecommityourchangesorstashthembeforeyoumerge.</pre><h4class="wp−block−heading"id="solution"><spanid="Solution">Solution:</span></h4><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git fetch origin master
gitdifforigin/master−−[local−path]</pre><preclass="EnlighterJSRAW"data−enlighter−language="generic"data−enlighter−theme=""data−enlighter−highlight=""data−enlighter−linenumbers=""data−enlighter−lineoffset=""data−enlighter−title=""data−enlighter−group=""> git add [local-path]
gt commit -m "change: in file [local-path]"</pre><h4 class="wp-block-heading" id="fatal-sha1-file-stdout-write-error-broken-pipe"><span id="fatal_sha1_file_8216ltstdoutgt8217_write_error_Broken_Pipe">fatal: sha1 file ‘<stdout>’ write error: Broken Pipe </span></h4><p>When using ssh to connect to the repositoriy, sometime, you got a timeout if you push to many files or if the files are to big</p><h4 class="wp-block-heading" id="one-possible-solution"><span id="One_possible_Solution">One possible Solution</span></h4><p>Configure ssh to use the following value</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">~/.ssh/config</pre><pre class="EnlighterJSRAW" data-enlighter-language="ini" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Host * ServerAliveInterval 30 ServerAliveCountMax 4</pre><h4 class="wp-block-heading" id="git-clone-file-name-to-long-on-windows"><span id="git_clone_file_name_to_long_on_windows">git clone: file name to long on windows</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --system core.longpaths true</pre><h4 class="wp-block-heading" id="git-config-global-user-email-some-email-com-throws-error-only-one-config-file-at-a-time"><span id="git_config_8211global_useremail_someemailcom_throws_error_only_one_config_file_at_a_time">git config –global user.email “some@email.com” throws “error: only one config file at a time.</span></h4><p>Try to unset GIT_CONFIG and then list your global config with</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG git config --global --list</pre><p>Other Links</p><p><a href="https://medium.com/flawless-app-stories/useful-git-commands-for-everyday-use-e1a4de64037d">Useful Git commands for everyday use</a></p><p><a href="https://medium.com/android-bits/10-useful-git-commands-you-always-need-b0d0a50b81e6">10 useful Git commands you always need</a></p><p><a href="https://orga.cat/posts/most-useful-git-commands">Most useful Git commands</a></p><p><a href="https://artandlogic.com/2014/01/git-cheat-sheet/">Git Cheat Sheet</a></p><p><a href="https://dzone.com/articles/useful-git-commands">Useful Git commands</a></p><h2 class="wp-block-heading" id="using-local-filesystem-as-respository-master"><span id="Using_local_Filesystem_as_Respository-Master">Using local Filesystem as Respository-Master</span></h2><h4 class="wp-block-heading" id="preparation"><span id="Preparation">Preparation</span></h4><p>Set environment variables for easy typing</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> REPOS=HOME/repos</pre><h4 class="wp-block-heading" id="create-repository"><span id="Create_Repository">Create Repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> mkdir REPOS
cd REPOS</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git init --bare src</pre><h4 class="wp-block-heading" id="create-src-folder"><span id="Create_src_folder">Create src folder</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> mkdir HOME/entw
cd HOME/entw
mkdir src
cd src
git init</pre><h4 class="wp-block-heading" id="create-some-content"><span id="Create_some_content">Create some content</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> touch README.md</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git add -A</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git commit -m "initial commit"</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git remote add origin REPOS/src
git remote -v
git push --set-upstream origin master
git push origin master</pre><h4 class="wp-block-heading" id="create-clone"><span id="Create_clone">Create clone</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> mkdir HOME/test
cd HOME/test</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git clone HOME/repos/src</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> cd src
ls -al
total 0
drwxr-xr-x 4 user wheel 128 19 Mär 18:48 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:48 ..
drwxr-xr-x 12 user wheel 384 19 Mär 18:48 .git
-rw-r--r-- 1 user wheel 0 19 Mär 18:48 README.md</pre><p>You will notice, that the file README.md is empty. Because it was ony created with touch.</p><h4 class="wp-block-heading" id="add-some-content-to-source-repository"><span id="Add_some_content_to_source_repository">Add some content to source repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> cd HOME/entw/src
echo "# This is the README.md from ENTW" >README.md
touch git_update
touch git_push</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> ls -al
total 16
drwxr-xr-x 6 user wheel 192 19 Mär 18:53 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:43 ..
drwxr-xr-x 12 user wheel 384 19 Mär 18:47 .git
-rw-r--r-- 1 user wheel 34 19 Mär 18:52 README.md
-rw-r--r-- 1 user wheel 0 19 Mär 18:53 git_push
-rw-r--r-- 1 user wheel 0 19 Mär 18:53 git_update</pre><h4 class="wp-block-heading" id="add-changes-to-repository"><span id="Add_changes_to_repository">Add changes to repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git add -A
git commit -m "-"
[master 106b27a] -
3 files changed, 1 insertion(+)
create mode 100644 git_push
create mode 100644 git_update</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git push --set-upstream origin master
Objekte aufzählen: 5, Fertig.
Zähle Objekte: 100
Delta-Kompression verwendet bis zu 8 Threads.
Komprimiere Objekte: 100
Schreibe Objekte: 100
Gesamt 3 (Delta 0), Wiederverwendet 0 (Delta 0)
To ..../repos/src
7ed6d3b..106b27a master -> master
Branch 'master' folgt nun Remote-Branch 'master' von 'origin'.</pre><h4 class="wp-block-heading" id="update-clone"><span id="Update_clone">Update clone</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> cd OME/test/src
git pull
# git fetch # This updates 'remote' portion of local repo.
# git reset --hard origin/<your-working-branch>
remote: Objekte aufzählen: 5, Fertig.
remote: Zähle Objekte: 100
remote: Komprimiere Objekte: 100
remote: Gesamt 3 (Delta 0), Wiederverwendet 0 (Delta 0)
Entpacke Objekte: 100
Von .../repos/src
7ed6d3b..106b27a master -> origin/master</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> git merge origin/master
Aktualisiere 7ed6d3b..106b27a
Fast-forward
README.md | 1 +
git_push | 0
git_update | 0
3 files changed, 1 insertion(+)
create mode 100644 git_push
create mode 100644 git_update</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> ls -al
total 16
drwxr-xr-x 6 user wheel 192 19 Mär 19:02 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:48 ..
drwxr-xr-x 14 user wheel 448 19 Mär 19:02 .git
-rw-r--r-- 1 user wheel 34 19 Mär 19:02 README.md
-rw-r--r-- 1 user wheel 0 19 Mär 19:02 git_push
-rw-r--r-- 1 user wheel 0 19 Mär 19:02 git_update</pre><h2 class="wp-block-heading" id="todo"><span id="TODO">TODO</span></h2><h4 class="wp-block-heading" id="see-changes-before-pulling-from-remote-git-repositoryf"><span id="See_changes_before_pulling_from_remote_git_repositoryf">See changes before pulling from remote git repository<a href="https://gist.github.com/jtdp/5443297#file-gistfile1-sh"><strong>f</strong></a></span></h4><figure class="wp-block-table"><table><tbody><tr><td># fetch the changes from the remote</td></tr><tr><td>git fetch origin</td></tr><tr></tr><tr><td># show commit logs of changes</td></tr><tr><td>git log master..origin/master</td></tr><tr></tr><tr><td># show diffs of changes</td></tr><tr><td>git diff master..origin/master</td></tr><tr></tr><tr><td># apply the changes by merge..</td></tr><tr><td>git merge origin/master</td></tr><tr></tr><tr><td># .. or just pull the changes</td></tr><tr><td>git pull</td></tr></tbody></table></figure><h4 class="wp-block-heading" id="you-want-to-push-your-local-files-to-remote-files"><span id="You_want_to_push_your_local_files_to_remote_files">You want to push your local files to remote files</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push -f <remote> <branch></pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push -f origin master</pre><h3 class="wp-block-heading" id="configure-hooks"><span id="Configure_Hooks">Configure Hooks</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --global core.hooksPath .githooks
mkdir .githooks
cp .git/hooks/* .githooks</pre><h4 class="wp-block-heading" id="prepare-commit"><span id="commit-msg">commit-msg</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
#
NAME=(git rev-parse --abbrev-ref HEAD)
DESCRIPTION=(git config branch."NAME".description)
echo "NAME"': '(cat "1") > "1"
if [ -n "DESCRIPTION" ]
then
echo "" >> "1"
echo DESCRIPTION >> "1"
fi</pre><h4 class="wp-block-heading" id="prepare-commit"><span id="prepare-commit">prepare-commit</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
#
COMMIT_MSG_FILE=1
COMMIT_SOURCE=2
SHA1=3
branchPath=(git symbolic-ref -q HEAD)
branchName={branchPath##*/}
if [ -n "branchName" ]; then
echo "branchName | (cat 1)" > 1
fi</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">file=(git config hooks.versionfilename)
if [[ -z file ]]
then
file=".version"
fi
# Version number
echo "(git rev-parse --abbrev-ref HEAD): (git describe --tags --long)" >file
exec git add file</pre><h4 class="wp-block-heading" id="pre-commit"><span id="pre-commit">pre-commit</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
_BRANCHPATH=(git symbolic-ref -q HEAD)
_BRANCHNAME={_BRANCHPATH##*/}
_TIMESTAMP="(date '+
echo "HOOK : 0"
echo "PARAMETER : '*''"
echo "BRANCHPATH: _BRANCHPATH"
echo "BRANCHNAME: _BRANCHNAME"
LOG() {
[[ "$GIT_COMMIT_DETAILED_LOGGING" == "YES" ]] && echo "LOG: $*"
}
REPLACE()
{
local _TYP; _TYP="$1"; shift
local _TAG; _TAG="$1"; shift
local _WITH; _WITH="$1"; shift
local _FILE; _FILE="$1"; shift
case "$_TYP" in
PYTHON) perl -pi -e 's/(\s*)(__DEPLOY_'${_TAG}'\s*=\s*)(".+")/${1}${2}"'"${_WITH}"'"/' "${_FILE}"
;;
*) LOG "Undefined typ '$TYP' for file $_FILE"
;;
esac
rm -f "${_FILE}.bak"
}
LOG "working on branch _BRANCH"
for _FILE in (git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
do
LOG "checking: _FILE"
# Only examine known text files
if [[ "_FILE" =~ [.](py) ]]; then
LOG "patching: _FILE"
REPLACE PYTHON TAG "_BRANCHNAME" "_FILE"
REPLACE PYTHON TIMESTAMP "_TIMESTAMP" "_FILE"
fi
done
</pre><h2 class="wp-block-heading" id="get-information"><span id="Get_Information">Get Information</span></h2><figure class="wp-block-table"><table><tbody><tr><td>git rev-parse –abbrev-ref HEAD</td><td>get branch name</td><td>feature/add-new-content</td></tr><tr><td>git symbolic-ref -q HEAD</td><td></td><td>refs/heads/<meta charset="utf-8">feature/add-new-content</td></tr><tr><td><meta charset="utf-8">git rev-parse –show-toplevel</td><td><meta charset="utf-8">show current path of git repository</td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="config"><span id="Config">Config</span></h2><h3 class="wp-block-heading" id="change-github-repository-for-local-clone"><span id="Change_Github_repository_for_local_clone">Change Github repository for local clone</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">cd <original repository>
git remote set-url origin https://github.com/<new git user>/<new project name>
git push -u origin master
</pre><h3 class="wp-block-heading" id="cr-lf-mapping"><span id="CRLF_Mapping">CR/LF Mapping</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config core.autocrlf true
git config --global core.safecrlf false</pre><h2 class="wp-block-heading" id="create-release"><span id="Create_Release">Create Release</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/bash
if [ # -ne 1 ]; then
echo "Syntax: release [VERSION]"
exit 1
fi
VERSION=1
# Create release
git flow release start VERSION || exit 1
GIT_MERGE_AUTOEDIT=no git flow release finish -m VERSION VERSION
# Publish release
git push origin HEAD --tags
# Merge release into develop
git checkout develop
git merge master</pre></pre>
<h3 class="wp-block-heading" id="show-location-of-configuration-files"><span id="Show_location_of_configuration_files">Show location of configuration files</span></h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --list --show-origin</pre><p>This dows not work, if you have set the environment var GIT_CONFIG. In this case, do</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
git config --global --list</pre><h2 class="wp-block-heading" id="edit-config-files"><span id="Edit_config_files">Edit config files</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --global</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --system</pre><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Configure the author name to be used with your commits.</td><td><code>git config --global user.name "XXX"</code></td></tr><tr><td>Configure the author email address to be used with your commits</td><td><code>git config --global user.email xxx@example.com</code></td></tr><tr><td>Will remove user credential details from the repository</td><td><code>git config --local credential.helper ""</code></td></tr><tr><td></td><td>git config —show-origin</td></tr><tr><td>List all currently configured remote repository URLs</td><td><code>git remote -v</code></td></tr><tr><td>If you haven’t connected your local repository to a remote server, To add a remote server to a local repository</td><td><code>git remote add origin <repo_url></code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-commit-and-push"><span id="Git_Commit_and_Push">Git Commit and Push</span></h2><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Create a file name <code>README.md</code> with <code>Readme content</code> content</td><td><code>echo "Readme content" >> README.md</code></td></tr><tr><td>List the files you’ve changed and those you still need to add or commit</td><td><code>git status</code></td></tr><tr><td>Add all or one file to staging</td><td><code>git add .</code> OR <code>git add file_name</code></td></tr><tr><td>Commit changes to head with message</td><td><code>git commit -m 'message'</code></td></tr><tr><td>Commit any files you’ve added with <code>git add</code>, and also commit any files you’ve changed since then</td><td><code>git commit -a</code></td></tr><tr><td>Send all commits from local repository to remote repository</td><td><code>git push</code></td></tr><tr><td>Do a <code>git push</code> and sets the default remote branch for the current local branch. So any future <code>git pull</code> command will attempt to bring in commits from the <code><remote-branch></code>into the current local branch</td><td><code>git push -u <remote-branch></code></td></tr><tr><td>Send changes to the master branch of your remote repository</td><td><code>git push origin master</code></td></tr><tr><td>Push a specific branch to your remote repository</td><td><code>git push origin <branch_name></code></td></tr><tr><td>Push all branches to your remote repository</td><td><code>git push --all origin</code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="working-with-the-git-workflow"><span id="Working_with_the_Git_Workflow">Working with the Git Workflow</span></h2><p>The following steps are based on a branching model, described <a href="https://nvie.com/posts/a-successful-git-branching-model/">here</a>.</p><figure class="wp-block-table"><table><tbody><tr><th>Name</th><th> Beschreibung</th></tr><tr><td>master</td><td></td></tr><tr><td>hotfixes</td></tr><tr><td>release</td></tr><tr><td>develop</td></tr><tr><td>feature</td></tr></tbody></table></figure><h3 class="wp-block-heading" id="Workflow-MitBranchesarbeiten"><span id="Working_with_branches">Working with branches</span></h3><h4 class="wp-block-heading" id="Workflow-Brancheserstellen"><span id="Create_branch_8216develop8217">Create branch ‘develop’</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone git@github.com:<USER>/<REPO>.git develop
$ cd develop
$ git checkout -b develop
$ git push --set-upstream origin develop</pre><h4 class="wp-block-heading" id="create-branch-feature-xxx"><span id="Create_branch_8216feature-xxx8217">Create branch ‘feature-xxx’</span></h4><p>We dont’t want do clone the whole repository, but only the files needed for the feature</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone -b develop -n --depth 1 git@github.com:<USER>/<REPO>.git feature-2.2.0
$ cd feature-2.2.0
</pre><h4 class="wp-block-heading" id="Workflow-Branchlöschen"><span id="Branch_loschen">Branch löschen</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git push origin -delete hotfix-1.2.1-compress-data</pre><h3 class="wp-block-heading" id="Workflow-Workflow-Cheatsheet"><span id="Workflow_8211_Cheatsheet">Workflow – Cheatsheet</span></h3><h4 class="wp-block-heading" id="working-with-branches"><span id="Working_with_branches-2">Working with branches</span></h4><p><strong>How to rename git local and remote branches</strong></p><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Check out branch with old name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git checkout feature-2.1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Rename branch</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m feature-2.01.02</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Checkin branch with new name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :feature-2.1.2 feature-2.01.02</pre></div></div><p><strong>1. Rename your local branch.</strong></p><p>If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.</p><p>If you are on the branch you want to rename:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m new-name</pre><p>If you are on a different branch:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old-name new-name</pre><p><strong>2. Delete the old-name remote branch and push the new-name local branch.</strong></p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :old-name new-name</pre><p><strong>3. Reset the upstream branch for the new-name local branch.</strong>Switch to the branch and then:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin -u new-name</pre><p>Or you as a fast way to do that, you can use these 3 steps: command in your terminal</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete old branch
git push --set-upstream origin new_branch # Push new branch, set local branch to track new remote</pre><figure class="wp-block-table"><table><tbody><tr><th>Neues Feature erstellen</th></tr><tr><td>Repository clonen</td><td>$ git checkout -b feature-1.2.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git checkout develop<br>$ git merge –no-ff feature-1.2.2 <br>$ git branch -d feature-1.2.2 <br>$ git push origin develop</td></tr><tr></tr></tbody></table></figure><figure class="wp-block-table"><table><tbody><tr><th>Neuen Hotfix erstelllen</th></tr><tr><td>Repository auschecken</td><td>$ git checkout -b hotfix-1.2.1 master</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git commit -a -m “hotfix: hotfix-1.2.1| compress mart”</td></tr><tr><td>Hotfix beenden</td><td>$ git checkout master<br>$ git merge –no-ff hotfix-1.2.1 <br>$ git tag -a 1.2.1</td></tr><tr><td>Hotfix in Master einchecken</td><td>$ git checkout develop<br>$ git merge –no-ff hotfix-1.2.1 </td></tr><tr><td>Hotfix Branch entfernen</td><td>$ git branch -d hotfix-1.2.1</td></tr><tr></tr></tbody></table></figure><figure class="wp-block-table"><table><tbody><tr><th>Neues Release erstellen:</th></tr><tr><td>Repository clonen</td><td>$ git checkout -b release-1.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git commit -a -m “release: changes for release 1.2”</td></tr><tr><td>Release beenden</td><td>$ git checkout master<br>$ git merge –no-ff release-1.2<br>$ git tag -a 1.2</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-flow"><span id="Git_Flow">Git Flow</span></h2><h4 class="wp-block-heading" id="initialize"><span id="Initialize">Initialize</span></h4><p>Start using git-flow by initializing it inside an existing git repository:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git flow init</pre><h4 class="wp-block-heading" id="start-a-new-feature"><span id="Start_a_new_feature">Start a new feature</span></h4><p>Development of new features starting from the ‘develop’ branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature start MYFEATURE</pre><h4 class="wp-block-heading" id="finish-up-a-feature"><span id="Finish_up_a_feature">Finish up a feature</span></h4><p>Finish the development of a feature. This action performs the following</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature finish MYFEATURE</pre><h4 class="wp-block-heading" id="publish-a-feature"><span id="Publish_a_feature">Publish a feature</span></h4><p>Publish a feature to the remote server so it can be used by other users.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature publish MYFEATURE</pre><h3 class="wp-block-heading" id="getting-a-published-feature"><span id="Getting_a_published_feature">Getting a published feature</span></h3><p>Get a feature published by another user.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature pull origin MYFEATURE</pre><p>You can track a feature on origin by using</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature track MYFEATURE</pre><h4 class="wp-block-heading" id="start-a-release"><span id="Start_a_release">Start a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release start RELEASE [BASE]</pre><p>It’s wise to publish the release branch after creating it to allow release commits by other developers. Do it similar to feature publishing with the command:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release publish RELEASE</pre><p>(You can track a remote release with the <br><code>git flow release track RELEASE</code>command)</p><h4 class="wp-block-heading" id="finish-up-a-release"><span id="Finish_up_a_release">Finish up a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release finish RELEASE</pre><p>Don’t forget to push your tags with <code>git push origin --tags</code></p><h4 class="wp-block-heading" id="hotfixes"><span id="Hotfixes">Hotfixes</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix start VERSION [BASENAME]</pre><h4 class="wp-block-heading" id="finish-a-hotfix"><span id="Finish_a_hotfix">Finish a hotfix</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix finish VERSION</pre><h2 class="wp-block-heading" id="usefull-commands"><span id="Usefull_commands">Usefull commands</span></h2><figure class="wp-block-table"><table><tbody><tr><th>basic commands</th><th>description</th></tr><tr><td>git init</td></tr><tr><td>git status [ -s ]</td><td>status of files and local repo</td></tr><tr><td>git ls-files</td><td>show files which are tracked by git</td></tr><tr><td>git log [ –oneline ]<br>git log [–oneline –graph –decorate –all]</td><td>shows commit history</td></tr><tr><td>git add <changed file><br>git add .git add -u</td><td>add single file to indexadd all files from the workspace to indexstage current workspace into index to cleanup inconsistencies</td></tr><tr><td>git commit [ -m ‘message’ ]</td><td>commit into local repo only</td></tr><tr><td>git push -u origin master</td><td>push the repo from local to remote repo</td></tr><tr><td>git help [option]</td><td>get help page for specific options</td></tr><tr><td>git config –global alias.bla “command”<br>git bla [– <filename>]</td><td>set alias bla to a specific commandexec alias (for specific file)</td></tr><tr><td>git mv fileA fileB<br>git commit -m “…..”</td><td>rename fileA to fileBand commit</td></tr><tr><td>git rm fileC<br>git commit -m “…..”</td><td>delete fileCand commit</td></tr><tr></tr><tr><th>advanced commands</th><th>description</th></tr><tr><td>git reset HEAD <filename></td><td>undo changes from index back to workspace</td></tr><tr><td>git checkout <filename><br>git checkout master<br>git checkout <branchname></td><td>checkout single file from local repo to workspacecheckout/switch to the master branchcheckout/switch to another branch</td></tr><tr><td>git checkout -b <new branchname><br>git branch <new branchname></td><td>create new branch and switch to it immediatelycreate new branch in the background, doesn’t switch to it</td></tr><tr><td>git branch</td><td>shows all available branches</td></tr><tr><td>git diff<br>git difftool</td><td>show differences of local and committed file<br>shows diff in vimdiff</td></tr><tr><td>git merge <other branch><br>git mergetool</td><td>merge other branch into master (current branch)manage the different files in vimdiff</td></tr><tr><td>git branch -d <branchname></td><td>delete branch (does NOT include merge)</td></tr><tr><td>git branch -m <new name></td><td>rename a</td></tr><tr><td>$ git diff master..development</td><td>compare two branches</td></tr><tr><td>git tag <mytag><br>git tag -a v1.0 -m “description”<br>git show v1.0</td><td>add an additional label/tag to a branchannotation tag with release informationshows details of tag v1.0</td></tr><tr><td>git stash</td></tr><tr><td>git reset <ID> [–soft | –mixed | –hard]<br>git reflog ….</td></tr><tr><td>git fetch ….</td><td>update local repo with changes from remote repo. (non destructive)</td></tr><tr><td>git pull …</td><td>update local repo with changes from remote repo. it does effectively a fetch and merge in one command</td></tr><tr><td>git clone https://<<em>username</em>>:<<em>token</em>>@github.com/<<em>organisation-space</em>>/<<em>repository</em>><br></td><td>download the remote repo into local workspace</td></tr><tr><td>git remote -v<br>git remote show origin</td><td>shows url of remote reposhows detail infos of a remote repo</td></tr><tr></tr><tr><td>.gitignore</td><td>contains filename to exclude from git</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-workflow"><span id="Git_Workflow">Git Workflow</span></h2><h3 class="wp-block-heading" id="release"><span id="Release">Release</span></h3><h4 class="wp-block-heading" id="creating-a-release-branch"><span id="Creating_a_release_branch">Creating a release branch</span></h4><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code>is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b release-1.2 develop</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-7 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>After creating a new branch and switching to it, we bump the version number. Here, <code>bump-version.sh</code> is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that <em>some</em> files change.) Then, the bumped version number is committed.</p><p>This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the <code>develop</code>branch). Adding large new features here is strictly prohibited. They must be merged into <code>develop</code>, and therefore, wait for the next big release.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ./bump-version.sh 1.2<br>
$ git branch -d release-1.2</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-8 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>When the state of the release branch is ready to become a real release, some actions need to be carried out.</p><p>First, the release branch is merged into <code>master</code> (since every commit on <code>master</code> is a new release <em>by definition</em>, remember).</p><p>Next, that commit on <code>master</code> must be tagged for easy future reference to this historical version.</p><p>Finally, the changes made on the release branch need to be merged back into <code>develop</code>, so that future releases also contain these bug fixes.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>The release is now done, and tagged for future reference.</p><p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop
$ git merge --no-ff release-1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.</p><p>Now we are really done and the release branch may be removed, since we don’t need it anymore:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git branch -d release-1.2</pre></div></div><h3 class="wp-block-heading" id="feature"><span id="Feature">Feature</span></h3><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/fb@2x-e1554287024987-700x261.png" alt="" class="wp-image-4387 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
$ .. do changes...
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><h4 class="wp-block-heading" id="creating-a-feature-branch"><span id="Creating_a_feature_branchnbsp">Creating a feature branch </span></h4><p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
Switched to a new branch "myfeature"
</pre><h4 class="wp-block-heading" id="incorporating-a-finished-feature-on-develop"><span id="Incorporating_a_finished_feature_on_developnbsp">Incorporating a finished feature on develop </span></h4><p>Finished features may be merged into the <code>develop</code> branch to definitely add them to the upcoming release:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop<
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop </pre></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-12 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.</p><p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily doneif the <code>--no-ff</code> flag was used.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><figure class="wp-block-image"><img class="lazy" decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="https://nvie.com/img/merge-without-ff@2x.png" alt=""></figure></div></div><h2 class="wp-block-heading" id="hotfix"><span id="Hotfix">Hotfix</span></h2><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/hotfix-branches@2x-e1554287153961-700x519.png" alt="" class="wp-image-4394 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b hotfix-1.2.1 master
export GIT_CURL_VERBOSE=1</pre><h4 class="wp-block-heading" id="error-message-your-local-changes-to-the-following-files-would-be-overwritten-by-merge"><span id="Error_Message_Your_local_changes_to_the_following_files_would_be_overwritten_by_merge">Error Message: Your local changes to the following files would be overwritten by merge: </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.</pre><h4 class="wp-block-heading" id="solution"><span id="Solution">Solution:</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git fetch origin master
$ gt commit -m "change: in file [local-path]"</pre><h4 class="wp-block-heading" id="fatal-sha1-file-stdout-write-error-broken-pipe"><span id="fatal_sha1_file_8216ltstdoutgt8217_write_error_Broken_Pipe">fatal: sha1 file ‘<stdout>’ write error: Broken Pipe </span></h4><p>When using ssh to connect to the repositoriy, sometime, you got a timeout if you push to many files or if the files are to big</p><h4 class="wp-block-heading" id="one-possible-solution"><span id="One_possible_Solution">One possible Solution</span></h4><p>Configure ssh to use the following value</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">~/.ssh/config</pre><pre class="EnlighterJSRAW" data-enlighter-language="ini" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Host *
ServerAliveInterval 30
ServerAliveCountMax 4</pre><h4 class="wp-block-heading" id="git-clone-file-name-to-long-on-windows"><span id="git_clone_file_name_to_long_on_windows">git clone: file name to long on windows</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --system core.longpaths true</pre><h4 class="wp-block-heading" id="git-config-global-user-email-some-email-com-throws-error-only-one-config-file-at-a-time"><span id="git_config_8211global_useremail_someemailcom_throws_error_only_one_config_file_at_a_time">git config –global user.email “some@email.com” throws “error: only one config file at a time.</span></h4><p>Try to unset GIT_CONFIG and then list your global config with</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
-rw-r--r-- 1 user wheel 019 Mär 18:48 README.md</pre><p>You will notice, that the file README.md is empty. Because it was ony created with touch.</p><h4 class="wp-block-heading" id="add-some-content-to-source-repository"><span id="Add_some_content_to_source_repository">Add some content to source repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cd $HOME/entw/src
$ echo "# This is the README.md from ENTW" >README.md
git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="
<h2 class="wp-block-heading" id="git-configuration"><span id="Git_Configuration">Git Configuration</span></h2>
<h3 class="wp-block-heading" id="show-location-of-configuration-files"><span id="Show_location_of_configuration_files">Show location of configuration files</span></h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --list --show-origin</pre><p>This dows not work, if you have set the environment var GIT_CONFIG. In this case, do</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
git config --global --list</pre><h2 class="wp-block-heading" id="edit-config-files"><span id="Edit_config_files">Edit config files</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --global</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --edit --system</pre><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Configure the author name to be used with your commits.</td><td><code>git config --global user.name "XXX"</code></td></tr><tr><td>Configure the author email address to be used with your commits</td><td><code>git config --global user.email xxx@example.com</code></td></tr><tr><td>Will remove user credential details from the repository</td><td><code>git config --local credential.helper ""</code></td></tr><tr><td></td><td>git config —show-origin</td></tr><tr><td>List all currently configured remote repository URLs</td><td><code>git remote -v</code></td></tr><tr><td>If you haven’t connected your local repository to a remote server, To add a remote server to a local repository</td><td><code>git remote add origin <repo_url></code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-commit-and-push"><span id="Git_Commit_and_Push">Git Commit and Push</span></h2><figure class="wp-block-table"><table><thead><tr><th>DESCRIPTION</th><th>GIT COMMAND</th></tr></thead><tbody><tr><td>Create a file name <code>README.md</code> with <code>Readme content</code> content</td><td><code>echo "Readme content" >> README.md</code></td></tr><tr><td>List the files you’ve changed and those you still need to add or commit</td><td><code>git status</code></td></tr><tr><td>Add all or one file to staging</td><td><code>git add .</code> OR <code>git add file_name</code></td></tr><tr><td>Commit changes to head with message</td><td><code>git commit -m 'message'</code></td></tr><tr><td>Commit any files you’ve added with <code>git add</code>, and also commit any files you’ve changed since then</td><td><code>git commit -a</code></td></tr><tr><td>Send all commits from local repository to remote repository</td><td><code>git push</code></td></tr><tr><td>Do a <code>git push</code> and sets the default remote branch for the current local branch. So any future <code>git pull</code> command will attempt to bring in commits from the <code><remote-branch></code>into the current local branch</td><td><code>git push -u <remote-branch></code></td></tr><tr><td>Send changes to the master branch of your remote repository</td><td><code>git push origin master</code></td></tr><tr><td>Push a specific branch to your remote repository</td><td><code>git push origin <branch_name></code></td></tr><tr><td>Push all branches to your remote repository</td><td><code>git push --all origin</code></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="working-with-the-git-workflow"><span id="Working_with_the_Git_Workflow">Working with the Git Workflow</span></h2><p>The following steps are based on a branching model, described <a href="https://nvie.com/posts/a-successful-git-branching-model/">here</a>.</p><figure class="wp-block-table"><table><tbody><tr><th>Name</th><th> Beschreibung</th></tr><tr><td>master</td><td></td></tr><tr><td>hotfixes</td></tr><tr><td>release</td></tr><tr><td>develop</td></tr><tr><td>feature</td></tr></tbody></table></figure><h3 class="wp-block-heading" id="Workflow-MitBranchesarbeiten"><span id="Working_with_branches">Working with branches</span></h3><h4 class="wp-block-heading" id="Workflow-Brancheserstellen"><span id="Create_branch_8216develop8217">Create branch ‘develop’</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone git@github.com:<USER>/<REPO>.git develop
$ cd develop
$ git checkout -b develop
$ git push --set-upstream origin develop</pre><h4 class="wp-block-heading" id="create-branch-feature-xxx"><span id="Create_branch_8216feature-xxx8217">Create branch ‘feature-xxx’</span></h4><p>We dont’t want do clone the whole repository, but only the files needed for the feature</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone -b develop -n --depth 1 git@github.com:<USER>/<REPO>.git feature-2.2.0
$ cd feature-2.2.0
</pre><h4 class="wp-block-heading" id="Workflow-Branchlöschen"><span id="Branch_loschen">Branch löschen</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git push origin -delete hotfix-1.2.1-compress-data</pre><h3 class="wp-block-heading" id="Workflow-Workflow-Cheatsheet"><span id="Workflow_8211_Cheatsheet">Workflow – Cheatsheet</span></h3><h4 class="wp-block-heading" id="working-with-branches"><span id="Working_with_branches-2">Working with branches</span></h4><p><strong>How to rename git local and remote branches</strong></p><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Check out branch with old name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git checkout feature-2.1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Rename branch</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m feature-2.01.02</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>Checkin branch with new name</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :feature-2.1.2 feature-2.01.02</pre></div></div><p><strong>1. Rename your local branch.</strong></p><p>If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.</p><p>If you are on the branch you want to rename:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m new-name</pre><p>If you are on a different branch:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old-name new-name</pre><p><strong>2. Delete the old-name remote branch and push the new-name local branch.</strong></p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin :old-name new-name</pre><p><strong>3. Reset the upstream branch for the new-name local branch.</strong>Switch to the branch and then:</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push origin -u new-name</pre><p>Or you as a fast way to do that, you can use these 3 steps: command in your terminal</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete old branch
git push --set-upstream origin new_branch # Push new branch, set local branch to track new remote</pre><figure class="wp-block-table"><table><tbody><tr><th>Neues Feature erstellen</th></tr><tr><td>Repository clonen</td><td>$ git checkout -b feature-1.2.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git checkout develop<br>$ git merge –no-ff feature-1.2.2 <br>$ git branch -d feature-1.2.2 <br>$ git push origin develop</td></tr><tr></tr></tbody></table></figure><figure class="wp-block-table"><table><tbody><tr><th>Neuen Hotfix erstelllen</th></tr><tr><td>Repository auschecken</td><td>$ git checkout -b hotfix-1.2.1 master</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git commit -a -m “hotfix: hotfix-1.2.1| compress mart”</td></tr><tr><td>Hotfix beenden</td><td>$ git checkout master<br>$ git merge –no-ff hotfix-1.2.1 <br>$ git tag -a 1.2.1</td></tr><tr><td>Hotfix in Master einchecken</td><td>$ git checkout develop<br>$ git merge –no-ff hotfix-1.2.1 </td></tr><tr><td>Hotfix Branch entfernen</td><td>$ git branch -d hotfix-1.2.1</td></tr><tr></tr></tbody></table></figure><figure class="wp-block-table"><table><tbody><tr><th>Neues Release erstellen:</th></tr><tr><td>Repository clonen</td><td>$ git checkout -b release-1.2 develop</td></tr><tr><td>Änderungen durchführen</td></tr><tr><td>Änderungen einchecken</td><td>$ git commit -a -m “release: changes for release 1.2”</td></tr><tr><td>Release beenden</td><td>$ git checkout master<br>$ git merge –no-ff release-1.2<br>$ git tag -a 1.2</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-flow"><span id="Git_Flow">Git Flow</span></h2><h4 class="wp-block-heading" id="initialize"><span id="Initialize">Initialize</span></h4><p>Start using git-flow by initializing it inside an existing git repository:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git flow init</pre><h4 class="wp-block-heading" id="start-a-new-feature"><span id="Start_a_new_feature">Start a new feature</span></h4><p>Development of new features starting from the ‘develop’ branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature start MYFEATURE</pre><h4 class="wp-block-heading" id="finish-up-a-feature"><span id="Finish_up_a_feature">Finish up a feature</span></h4><p>Finish the development of a feature. This action performs the following</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature finish MYFEATURE</pre><h4 class="wp-block-heading" id="publish-a-feature"><span id="Publish_a_feature">Publish a feature</span></h4><p>Publish a feature to the remote server so it can be used by other users.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature publish MYFEATURE</pre><h3 class="wp-block-heading" id="getting-a-published-feature"><span id="Getting_a_published_feature">Getting a published feature</span></h3><p>Get a feature published by another user.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature pull origin MYFEATURE</pre><p>You can track a feature on origin by using</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow feature track MYFEATURE</pre><h4 class="wp-block-heading" id="start-a-release"><span id="Start_a_release">Start a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release start RELEASE [BASE]</pre><p>It’s wise to publish the release branch after creating it to allow release commits by other developers. Do it similar to feature publishing with the command:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release publish RELEASE</pre><p>(You can track a remote release with the <br><code>git flow release track RELEASE</code>command)</p><h4 class="wp-block-heading" id="finish-up-a-release"><span id="Finish_up_a_release">Finish up a release</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow release finish RELEASE</pre><p>Don’t forget to push your tags with <code>git push origin --tags</code></p><h4 class="wp-block-heading" id="hotfixes"><span id="Hotfixes">Hotfixes</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix start VERSION [BASENAME]</pre><h4 class="wp-block-heading" id="finish-a-hotfix"><span id="Finish_a_hotfix">Finish a hotfix</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git flow hotfix finish VERSION</pre><h2 class="wp-block-heading" id="usefull-commands"><span id="Usefull_commands">Usefull commands</span></h2><figure class="wp-block-table"><table><tbody><tr><th>basic commands</th><th>description</th></tr><tr><td>git init</td></tr><tr><td>git status [ -s ]</td><td>status of files and local repo</td></tr><tr><td>git ls-files</td><td>show files which are tracked by git</td></tr><tr><td>git log [ –oneline ]<br>git log [–oneline –graph –decorate –all]</td><td>shows commit history</td></tr><tr><td>git add <changed file><br>git add .git add -u</td><td>add single file to indexadd all files from the workspace to indexstage current workspace into index to cleanup inconsistencies</td></tr><tr><td>git commit [ -m ‘message’ ]</td><td>commit into local repo only</td></tr><tr><td>git push -u origin master</td><td>push the repo from local to remote repo</td></tr><tr><td>git help [option]</td><td>get help page for specific options</td></tr><tr><td>git config –global alias.bla “command”<br>git bla [– <filename>]</td><td>set alias bla to a specific commandexec alias (for specific file)</td></tr><tr><td>git mv fileA fileB<br>git commit -m “…..”</td><td>rename fileA to fileBand commit</td></tr><tr><td>git rm fileC<br>git commit -m “…..”</td><td>delete fileCand commit</td></tr><tr></tr><tr><th>advanced commands</th><th>description</th></tr><tr><td>git reset HEAD <filename></td><td>undo changes from index back to workspace</td></tr><tr><td>git checkout <filename><br>git checkout master<br>git checkout <branchname></td><td>checkout single file from local repo to workspacecheckout/switch to the master branchcheckout/switch to another branch</td></tr><tr><td>git checkout -b <new branchname><br>git branch <new branchname></td><td>create new branch and switch to it immediatelycreate new branch in the background, doesn’t switch to it</td></tr><tr><td>git branch</td><td>shows all available branches</td></tr><tr><td>git diff<br>git difftool</td><td>show differences of local and committed file<br>shows diff in vimdiff</td></tr><tr><td>git merge <other branch><br>git mergetool</td><td>merge other branch into master (current branch)manage the different files in vimdiff</td></tr><tr><td>git branch -d <branchname></td><td>delete branch (does NOT include merge)</td></tr><tr><td>git branch -m <new name></td><td>rename a</td></tr><tr><td>$ git diff master..development</td><td>compare two branches</td></tr><tr><td>git tag <mytag><br>git tag -a v1.0 -m “description”<br>git show v1.0</td><td>add an additional label/tag to a branchannotation tag with release informationshows details of tag v1.0</td></tr><tr><td>git stash</td></tr><tr><td>git reset <ID> [–soft | –mixed | –hard]<br>git reflog ….</td></tr><tr><td>git fetch ….</td><td>update local repo with changes from remote repo. (non destructive)</td></tr><tr><td>git pull …</td><td>update local repo with changes from remote repo. it does effectively a fetch and merge in one command</td></tr><tr><td>git clone https://<<em>username</em>>:<<em>token</em>>@github.com/<<em>organisation-space</em>>/<<em>repository</em>><br></td><td>download the remote repo into local workspace</td></tr><tr><td>git remote -v<br>git remote show origin</td><td>shows url of remote reposhows detail infos of a remote repo</td></tr><tr></tr><tr><td>.gitignore</td><td>contains filename to exclude from git</td></tr></tbody></table></figure><h2 class="wp-block-heading" id="git-workflow"><span id="Git_Workflow">Git Workflow</span></h2><h3 class="wp-block-heading" id="release"><span id="Release">Release</span></h3><h4 class="wp-block-heading" id="creating-a-release-branch"><span id="Creating_a_release_branch">Creating a release branch</span></h4><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code>is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b release-1.2 develop</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-7 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>After creating a new branch and switching to it, we bump the version number. Here, <code>bump-version.sh</code> is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that <em>some</em> files change.) Then, the bumped version number is committed.</p><p>This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the <code>develop</code>branch). Adding large new features here is strictly prohibited. They must be merged into <code>develop</code>, and therefore, wait for the next big release.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ./bump-version.sh 1.2<br>
$ git commit -a -m "Version 1.2"</pre></div></div><h4 class="wp-block-heading" id="finishing-a-release-branch"><span id="Finishing_a_release_branchnbsp"> Finishing a release branch </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2
$ git checkout develop
$ git merge --no-ff release-1.2
$ git branch -d release-1.2</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-8 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>When the state of the release branch is ready to become a real release, some actions need to be carried out.</p><p>First, the release branch is merged into <code>master</code> (since every commit on <code>master</code> is a new release <em>by definition</em>, remember).</p><p>Next, that commit on <code>master</code> must be tagged for easy future reference to this historical version.</p><p>Finally, the changes made on the release branch need to be merged back into <code>develop</code>, so that future releases also contain these bug fixes.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>The release is now done, and tagged for future reference.</p><p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop
$ git merge --no-ff release-1.2</pre></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p>This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.</p><p>Now we are really done and the release branch may be removed, since we don’t need it anymore:</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git branch -d release-1.2</pre></div></div><h3 class="wp-block-heading" id="feature"><span id="Feature">Feature</span></h3><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/fb@2x-e1554287024987-700x261.png" alt="" class="wp-image-4387 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
$ .. do changes...
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop</pre><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><h4 class="wp-block-heading" id="creating-a-feature-branch"><span id="Creating_a_feature_branchnbsp">Creating a feature branch </span></h4><p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b myfeature develop
Switched to a new branch "myfeature"
</pre><h4 class="wp-block-heading" id="incorporating-a-finished-feature-on-develop"><span id="Incorporating_a_finished_feature_on_developnbsp">Incorporating a finished feature on develop </span></h4><p>Finished features may be merged into the <code>develop</code> branch to definitely add them to the upcoming release:</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout develop<
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop </pre></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"></div></div><div class="wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-12 wp-block-columns-is-layout-flex"><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><p> The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.</p><p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the <code>--no-ff</code> flag was used.</p></div><div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"><figure class="wp-block-image"><img class="lazy" decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="https://nvie.com/img/merge-without-ff@2x.png" alt=""></figure></div></div><h2 class="wp-block-heading" id="hotfix"><span id="Hotfix">Hotfix</span></h2><figure class="wp-block-image"><img decoding="async" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E" data-src="http://blog.via-internet.de/wp-content/uploads/2019/03/hotfix-branches@2x-e1554287153961-700x519.png" alt="" class="wp-image-4394 lazy"></figure><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git checkout -b hotfix-1.2.1 master
$ ... do changes ...
$ git commit -a -m "Hotfix Version 1.2.1"
$ .. fix bug
$ git commit -m "Fixed severe production problem"
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
# incude hotfix into develop
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
# finally, remove hotfix branch
$ git branch -d hotfix-1.2.1</pre><h2 class="wp-block-heading" id="troubleshooting"><span id="Troubleshooting">Troubleshooting</span></h2><h4 class="wp-block-heading" id="debugging-github-errors"><span id="Debugging_Github_Errors">Debugging Github Errors</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1</pre><h4 class="wp-block-heading" id="error-message-your-local-changes-to-the-following-files-would-be-overwritten-by-merge"><span id="Error_Message_Your_local_changes_to_the_following_files_would_be_overwritten_by_merge">Error Message: Your local changes to the following files would be overwritten by merge: </span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.</pre><h4 class="wp-block-heading" id="solution"><span id="Solution">Solution:</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git fetch origin master
$ git diff origin/master -- [local-path]</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git add [local-path]
$ gt commit -m "change: in file [local-path]"</pre><h4 class="wp-block-heading" id="fatal-sha1-file-stdout-write-error-broken-pipe"><span id="fatal_sha1_file_8216ltstdoutgt8217_write_error_Broken_Pipe">fatal: sha1 file ‘<stdout>’ write error: Broken Pipe </span></h4><p>When using ssh to connect to the repositoriy, sometime, you got a timeout if you push to many files or if the files are to big</p><h4 class="wp-block-heading" id="one-possible-solution"><span id="One_possible_Solution">One possible Solution</span></h4><p>Configure ssh to use the following value</p><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">~/.ssh/config</pre><pre class="EnlighterJSRAW" data-enlighter-language="ini" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Host *
ServerAliveInterval 30
ServerAliveCountMax 4</pre><h4 class="wp-block-heading" id="git-clone-file-name-to-long-on-windows"><span id="git_clone_file_name_to_long_on_windows">git clone: file name to long on windows</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --system core.longpaths true</pre><h4 class="wp-block-heading" id="git-config-global-user-email-some-email-com-throws-error-only-one-config-file-at-a-time"><span id="git_config_8211global_useremail_someemailcom_throws_error_only_one_config_file_at_a_time">git config –global user.email “some@email.com” throws “error: only one config file at a time.</span></h4><p>Try to unset GIT_CONFIG and then list your global config with</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">unset GIT_CONFIG
git config --global --list</pre><p>Other Links</p><p><a href="https://medium.com/flawless-app-stories/useful-git-commands-for-everyday-use-e1a4de64037d">Useful Git commands for everyday use</a></p><p><a href="https://medium.com/android-bits/10-useful-git-commands-you-always-need-b0d0a50b81e6">10 useful Git commands you always need</a></p><p><a href="https://orga.cat/posts/most-useful-git-commands">Most useful Git commands</a></p><p><a href="https://artandlogic.com/2014/01/git-cheat-sheet/">Git Cheat Sheet</a></p><p><a href="https://dzone.com/articles/useful-git-commands">Useful Git commands</a></p><h2 class="wp-block-heading" id="using-local-filesystem-as-respository-master"><span id="Using_local_Filesystem_as_Respository-Master">Using local Filesystem as Respository-Master</span></h2><h4 class="wp-block-heading" id="preparation"><span id="Preparation">Preparation</span></h4><p>Set environment variables for easy typing</p><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ REPOS=$HOME/repos</pre><h4 class="wp-block-heading" id="create-repository"><span id="Create_Repository">Create Repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ mkdir $REPOS
$ cd $REPOS</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git init --bare src</pre><h4 class="wp-block-heading" id="create-src-folder"><span id="Create_src_folder">Create src folder</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ mkdir $HOME/entw
$ cd $HOME/entw
$ mkdir src
$ cd src
$ git init</pre><h4 class="wp-block-heading" id="create-some-content"><span id="Create_some_content">Create some content</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ touch README.md</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git add -A</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git commit -m "initial commit"</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git remote add origin $REPOS/src
$ git remote -v
$ git push --set-upstream origin master
$ git push origin master</pre><h4 class="wp-block-heading" id="create-clone"><span id="Create_clone">Create clone</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ mkdir $HOME/test
$ cd $HOME/test</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git clone $HOME/repos/src</pre><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cd src
$ ls -al
total 0
drwxr-xr-x 4 user wheel 128 19 Mär 18:48 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:48 ..
drwxr-xr-x 12 user wheel 384 19 Mär 18:48 .git
-rw-r--r-- 1 user wheel 0 19 Mär 18:48 README.md</pre><p>You will notice, that the file README.md is empty. Because it was ony created with touch.</p><h4 class="wp-block-heading" id="add-some-content-to-source-repository"><span id="Add_some_content_to_source_repository">Add some content to source repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cd $HOME/entw/src
$ echo "# This is the README.md from ENTW" >README.md
$ touch git_update
$ touch git_push</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ls -al
total 16
drwxr-xr-x 6 user wheel 192 19 Mär 18:53 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:43 ..
drwxr-xr-x 12 user wheel 384 19 Mär 18:47 .git
-rw-r--r-- 1 user wheel 34 19 Mär 18:52 README.md
-rw-r--r-- 1 user wheel 0 19 Mär 18:53 git_push
-rw-r--r-- 1 user wheel 0 19 Mär 18:53 git_update</pre><h4 class="wp-block-heading" id="add-changes-to-repository"><span id="Add_changes_to_repository">Add changes to repository</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git add -A
$ git commit -m "-"
[master 106b27a] -
3 files changed, 1 insertion(+)
create mode 100644 git_push
create mode 100644 git_update</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git push --set-upstream origin master
Objekte aufzählen: 5, Fertig.
Zähle Objekte: 100
Delta-Kompression verwendet bis zu 8 Threads.
Komprimiere Objekte: 100
Schreibe Objekte: 100
Gesamt 3 (Delta 0), Wiederverwendet 0 (Delta 0)
To ..../repos/src
7ed6d3b..106b27a master -> master
Branch 'master' folgt nun Remote-Branch 'master' von 'origin'.</pre><h4 class="wp-block-heading" id="update-clone"><span id="Update_clone">Update clone</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ cd $OME/test/src
$ git pull
# git fetch # This updates 'remote' portion of local repo.
# git reset --hard origin/<your-working-branch>
remote: Objekte aufzählen: 5, Fertig.
remote: Zähle Objekte: 100
remote: Komprimiere Objekte: 100
remote: Gesamt 3 (Delta 0), Wiederverwendet 0 (Delta 0)
Entpacke Objekte: 100
Von .../repos/src
7ed6d3b..106b27a master -> origin/master</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ git merge origin/master
Aktualisiere 7ed6d3b..106b27a
Fast-forward
README.md | 1 +
git_push | 0
git_update | 0
3 files changed, 1 insertion(+)
create mode 100644 git_push
create mode 100644 git_update</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">$ ls -al
total 16
drwxr-xr-x 6 user wheel 192 19 Mär 19:02 .
drwxr-xr-x 3 user wheel 96 19 Mär 18:48 ..
drwxr-xr-x 14 user wheel 448 19 Mär 19:02 .git
-rw-r--r-- 1 user wheel 34 19 Mär 19:02 README.md
-rw-r--r-- 1 user wheel 0 19 Mär 19:02 git_push
-rw-r--r-- 1 user wheel 0 19 Mär 19:02 git_update</pre><h2 class="wp-block-heading" id="todo"><span id="TODO">TODO</span></h2><h4 class="wp-block-heading" id="see-changes-before-pulling-from-remote-git-repositoryf"><span id="See_changes_before_pulling_from_remote_git_repositoryf">See changes before pulling from remote git repository<a href="https://gist.github.com/jtdp/5443297#file-gistfile1-sh"><strong>f</strong></a></span></h4><figure class="wp-block-table"><table><tbody><tr><td># fetch the changes from the remote</td></tr><tr><td>git fetch origin</td></tr><tr></tr><tr><td># show commit logs of changes</td></tr><tr><td>git log master..origin/master</td></tr><tr></tr><tr><td># show diffs of changes</td></tr><tr><td>git diff master..origin/master</td></tr><tr></tr><tr><td># apply the changes by merge..</td></tr><tr><td>git merge origin/master</td></tr><tr></tr><tr><td># .. or just pull the changes</td></tr><tr><td>git pull</td></tr></tbody></table></figure><h4 class="wp-block-heading" id="you-want-to-push-your-local-files-to-remote-files"><span id="You_want_to_push_your_local_files_to_remote_files">You want to push your local files to remote files</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push -f <remote> <branch></pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git push -f origin master</pre><h3 class="wp-block-heading" id="configure-hooks"><span id="Configure_Hooks">Configure Hooks</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config --global core.hooksPath .githooks
mkdir .githooks
cp .git/hooks/* .githooks</pre><h4 class="wp-block-heading" id="prepare-commit"><span id="commit-msg">commit-msg</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
#
NAME=$(git rev-parse --abbrev-ref HEAD)
DESCRIPTION=$(git config branch."$NAME".description)
echo "$NAME"': '$(cat "$1") > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
echo $DESCRIPTION >> "$1"
fi</pre><h4 class="wp-block-heading" id="prepare-commit"><span id="prepare-commit">prepare-commit</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
#
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
branchPath=$(git symbolic-ref -q HEAD)
branchName=${branchPath##*/}
if [ -n "$branchName" ]; then
echo "$branchName | $(cat $1)" > $1
fi</pre><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">file=$(git config hooks.versionfilename)
if [[ -z $file ]]
then
file=".version"
fi
# Version number
echo "$(git rev-parse --abbrev-ref HEAD): $(git describe --tags --long)" >$file
exec git add $file</pre><h4 class="wp-block-heading" id="pre-commit"><span id="pre-commit">pre-commit</span></h4><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
_BRANCHPATH=$(git symbolic-ref -q HEAD)
_BRANCHNAME=${_BRANCHPATH##*/}
_TIMESTAMP="$(date '+
echo "HOOK : $0"
echo "PARAMETER : '$*''"
echo "BRANCHPATH: $_BRANCHPATH"
echo "BRANCHNAME: $_BRANCHNAME"
LOG() {
[[ "$GIT_COMMIT_DETAILED_LOGGING" == "YES" ]] && echo "LOG: $*"
}
REPLACE()
{
local _TYP; _TYP="$1"; shift
local _TAG; _TAG="$1"; shift
local _WITH; _WITH="$1"; shift
local _FILE; _FILE="$1"; shift
case "$_TYP" in
PYTHON) perl -pi -e 's/(\s*)(__DEPLOY_'${_TAG}'\s*=\s*)(".+")/${1}${2}"'"${_WITH}"'"/' "${_FILE}"
;;
*) LOG "Undefined typ '$TYP' for file $_FILE"
;;
esac
rm -f "${_FILE}.bak"
}
LOG "working on branch $_BRANCH"
for _FILE in $(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
do
LOG "checking: $_FILE"
# Only examine known text files
if [[ "$_FILE" =~ [.](py)$ ]]; then
LOG "patching: $_FILE"
REPLACE PYTHON TAG "$_BRANCHNAME" "$_FILE"
REPLACE PYTHON TIMESTAMP "$_TIMESTAMP" "$_FILE"
fi
done
</pre><h2 class="wp-block-heading" id="get-information"><span id="Get_Information">Get Information</span></h2><figure class="wp-block-table"><table><tbody><tr><td>git rev-parse –abbrev-ref HEAD</td><td>get branch name</td><td>feature/add-new-content</td></tr><tr><td>git symbolic-ref -q HEAD</td><td></td><td>refs/heads/<meta charset="utf-8">feature/add-new-content</td></tr><tr><td><meta charset="utf-8">git rev-parse –show-toplevel</td><td><meta charset="utf-8">show current path of git repository</td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure><h2 class="wp-block-heading" id="config"><span id="Config">Config</span></h2><h3 class="wp-block-heading" id="change-github-repository-for-local-clone"><span id="Change_Github_repository_for_local_clone">Change Github repository for local clone</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">cd <original repository>
git remote set-url origin https://github.com/<new git user>/<new project name>
git push -u origin master
</pre><h3 class="wp-block-heading" id="cr-lf-mapping"><span id="CRLF_Mapping">CR/LF Mapping</span></h3><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">git config core.autocrlf true
git config --global core.safecrlf false</pre><h2 class="wp-block-heading" id="create-release"><span id="Create_Release">Create Release</span></h2><pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/bash
if [ $# -ne 1 ]; then
echo "Syntax: release [VERSION]"
exit 1
fi
VERSION=$1
# Create release
git flow release start $VERSION || exit 1
GIT_MERGE_AUTOEDIT=no git flow release finish -m $VERSION $VERSION
# Publish release
git push origin HEAD --tags
# Merge release into develop
git checkout develop
git merge master</pre>
This dows not work, if you have set the environment var GIT_CONFIG. In this case, do
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
unset GIT_CONFIG
git config --global --list
unset GIT_CONFIG
git config --global --list
unset GIT_CONFIG
git config --global --list
Edit config files
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git config --edit --global
git config --edit --global
git config --edit --global
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git config --edit --system
git config --edit --system
git config --edit --system
DESCRIPTION
GIT COMMAND
Configure the author name to be used with your commits.
git config --global user.name "XXX"
Configure the author email address to be used with your commits
git config --global user.email xxx@example.com
Will remove user credential details from the repository
git config --local credential.helper ""
git config —show-origin
List all currently configured remote repository URLs
git remote -v
If you haven’t connected your local repository to a remote server, To add a remote server to a local repository
git remote add origin <repo_url>
Git Commit and Push
DESCRIPTION
GIT COMMAND
Create a file name README.md with Readme content content
echo "Readme content" >> README.md
List the files you’ve changed and those you still need to add or commit
git status
Add all or one file to staging
git add . OR git add file_name
Commit changes to head with message
git commit -m 'message'
Commit any files you’ve added with git add, and also commit any files you’ve changed since then
git commit -a
Send all commits from local repository to remote repository
git push
Do a git push and sets the default remote branch for the current local branch. So any future git pull command will attempt to bring in commits from the <remote-branch>into the current local branch
git push -u <remote-branch>
Send changes to the master branch of your remote repository
git push origin master
Push a specific branch to your remote repository
git push origin <branch_name>
Push all branches to your remote repository
git push --all origin
Working with the Git Workflow
The following steps are based on a branching model, described here.
If you have named a branch incorrectly AND pushed this to the remote repository follow these steps before any other developers get a chance to jump on you and give you shit for not correctly following naming conventions.
If you are on the branch you want to rename:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git branch -m new-name
git branch -m new-name
git branch -m new-name
If you are on a different branch:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git branch -m old-name new-name
git branch -m old-name new-name
git branch -m old-name new-name
2. Delete the old-name remote branch and push the new-name local branch.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git push origin :old-name new-name
git push origin :old-name new-name
git push origin :old-name new-name
3. Reset the upstream branch for the new-name local branch.Switch to the branch and then:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git push origin -u new-name
git push origin -u new-name
git push origin -u new-name
Or you as a fast way to do that, you can use these 3 steps: command in your terminal
$ git commit -a -m “release: changes for release 1.2”
Release beenden
$ git checkout master $ git merge –no-ff release-1.2 $ git tag -a 1.2
Git Flow
Initialize
Start using git-flow by initializing it inside an existing git repository:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ git flow init
$ git flow init
$ git flow init
Start a new feature
Development of new features starting from the ‘develop’ branch.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow feature start MYFEATURE
git flow feature start MYFEATURE
git flow feature start MYFEATURE
Finish up a feature
Finish the development of a feature. This action performs the following
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow feature finish MYFEATURE
git flow feature finish MYFEATURE
git flow feature finish MYFEATURE
Publish a feature
Publish a feature to the remote server so it can be used by other users.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow feature publish MYFEATURE
git flow feature publish MYFEATURE
git flow feature publish MYFEATURE
Getting a published feature
Get a feature published by another user.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow feature pull origin MYFEATURE
git flow feature pull origin MYFEATURE
git flow feature pull origin MYFEATURE
You can track a feature on origin by using
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow feature track MYFEATURE
git flow feature track MYFEATURE
git flow feature track MYFEATURE
Start a release
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow release start RELEASE [BASE]
git flow release start RELEASE [BASE]
git flow release start RELEASE [BASE]
It’s wise to publish the release branch after creating it to allow release commits by other developers. Do it similar to feature publishing with the command:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow release publish RELEASE
git flow release publish RELEASE
git flow release publish RELEASE
(You can track a remote release with the git flow release track RELEASEcommand)
Finish up a release
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git flow release finish RELEASE
git flow release finish RELEASE
git flow release finish RELEASE
Don’t forget to push your tags with git push origin --tags
shows url of remote reposhows detail infos of a remote repo
.gitignore
contains filename to exclude from git
Git Workflow
Release
Creating a release branch
Release branches are created from the develop branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of developis ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ git checkout -b release-1.2 develop
$ git checkout -b release-1.2 develop
$ git checkout -b release-1.2 develop
After creating a new branch and switching to it, we bump the version number. Here, bump-version.sh is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that some files change.) Then, the bumped version number is committed.
This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the developbranch). Adding large new features here is strictly prohibited. They must be merged into develop, and therefore, wait for the next big release.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ ./bump-version.sh1.2<br>
$ git commit -a -m "Version 1.2"
$ ./bump-version.sh 1.2<br>
$ git commit -a -m "Version 1.2"
$ ./bump-version.sh 1.2<br>
$ git commit -a -m "Version 1.2"
The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.
In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the --no-ff flag was used.
Hotfix
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ git checkout -b hotfix-1.2.1 master
$ ... do changes ...
$ git commit -a -m "Hotfix Version 1.2.1"
$ .. fix bug
$ git commit -m "Fixed severe production problem"
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
# incude hotfix into develop
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
# finally, remove hotfix branch
$ git branch -d hotfix-1.2.1
$ git checkout -b hotfix-1.2.1 master
$ ... do changes ...
$ git commit -a -m "Hotfix Version 1.2.1"
$ .. fix bug
$ git commit -m "Fixed severe production problem"
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
# incude hotfix into develop
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
# finally, remove hotfix branch
$ git branch -d hotfix-1.2.1
$ git checkout -b hotfix-1.2.1 master
$ ... do changes ...
$ git commit -a -m "Hotfix Version 1.2.1"
$ .. fix bug
$ git commit -m "Fixed severe production problem"
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
# incude hotfix into develop
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
# finally, remove hotfix branch
$ git branch -d hotfix-1.2.1
Error Message: Your local changes to the following files would be overwritten by merge:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.
error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.
error: Your local changes to the following files would be overwritten by merge:<br>
README.md<br>
Please commit your changes or stash them before you merge.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the ...
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Leave a Reply