Home

GIT - vspdev

image

Contents

1. Listing 21 Configuring git 1 gt git config global user name Patrick Emil Zoerner 2 gt git config global user email zoerner vsp ag 3 gt git config global github user paddyez 4 gt git config global github token 0123456789yourf0123456789token 5 Colors for black background and green as font color 6 gt git config global color branch current yellow bold 2 4 Config file 14 gt git config global color branch remote cyan bold gt git config global color diff new yellow bold gt git config global color diff old red bold gt git config global color diff meta cyan bold gt git config global color diff frag white bold gt git config global color diff commit white bold gt git config global color status added yellow bold gt git config global color status changed cyan bold gt git config global color status untracked red bold Alternatively and if you know what you are doing you can edit the file gitconfig 20 21 22 23 24 25 Listing 22 gitconfig user name Patrick Emil Zoerner email zoerner vsp ag github user paddyez token 0123456789yourf0123456789token merge tool vimdiff diff color auto alias st status ci commit co checkout br branch di diff ignore all space color branch current yellow bold remote cyan bold eolor E d
2. On a conflict during pull rebase it can happen that the rebase fails In that case you fall out of the current branch and find yourself in no branch This means you have a detached head The origin master tells git to pull from master in the remote repository Specifying so ensures that git does not attempt to pull from a local branch On line ten of listing 1 the local configuration of the server is played back using pop The command removes the last stashed state from the stash applying it to the current working directory Basically it is an undo of line four This can fail with conflicts Listing 3 Pulling 1 gt git pull rebase origin master 2 gt git pull upstream aoe_modifications Understanding push The push command needs to know to which remote repos itory and to which branch it should put the new commits The remote usually is origin but the branch is mostly the current branch you work on Listing 4 Pushing gt git push origin master 2 gt git push upsteam aoe_modifications When nothing else is specified simple ist the new default e simple like upstream but refuses to push if the upstream branch s name 1 1 Getting started 4 is different from the local one This is the safest option and is well suited for beginners It will become the default in Git 2 0 s nothing do not push anything e matching push all branches having the same name in both ends This is for t
3. git commit amend m your new message 1 4 Files in the git repository 8 This option can be also used when you forgot to commit a file in a commit 1 4 Files in the git repository The entire typo3conf folder without the temp_XYZ php files and the depreca tion_XYZ log files is in the repository including the subfolder ext with all the extensions Additionally there is a subfolder sql_tables_git This folder contains TemlaVoila object TO and datastructure DS additionally the TypoScript table sys_template Parts of the fileadmin folder are also in the repository Basically all the template files html css js jpg and png are kept here 1 5 Git log Listing 11 Log for file 1 git log p FILEADMIN 2 Advanced Listing 12 Get an overview of remote branches 1 Get the remote changes 2 gt git fetch 3 Show all branches 4 gt git remote show origin 5 Show all known branches 6 gt git branch a 2 p Restoring a branch from remote Listing 13 Restoring a branch from remote 1 gt git co origin master b master 2 2 Merge conflicts On merge conflicts listing 14 there are mostly three stages of the files involved base 1 ours 2 and theirs 3 see listing 15 Files without merge conflict have only one stage stage namely 0 Sometimes there is no ours or no theirs That happens when the file is not existent in one repository Base is the common sou
4. new yellow bold old red bold meta cyan bold frag white bold commit white bold 2 5 Make non git repository a git repository 15 color status added yellow bold changed cyan bold untracked red bold 2 5 Make non git repository a git repository 2 git remote add origin git git vsp ag 3 git pull rebase origin master 2 6 Install a git public repository on debian Listing 23 Installing 1 gt sudo apt get install git core gitweb 2 gt sudo mkdir var www git 3 gt d var cache git sudo mkdir var cache git 4 gt sudo vim etc apache2 sites available git 6 lt VirtualHost 80 gt 7 ServerName git 8 DocumentRoot var www git 9 lt Directory var www git gt 10 Allow from all 11 AllowOverride all 12 Order allow deny 13 Options ExecCGI 14 lt Files gitweb cgi gt 15 SetHandler cgi script 16 lt Files gt 17 lt Directory gt 18 DirectoryIndex gitweb cgi 2 6 Install a git public repository on debian 16 19 SetEnv GITWEB_CONFIG etc gitweb conf 21 CustomLog var log apache2 git_access log combined 22 ErrorLog var log apache2 git_error log 23 RewriteLog var log apache2 git_rewrite log 24 RewriteLogLevel 3 25 lt VirtualHost gt 26 gt 8 27 gt sudo a2ensite git 23 gt sudo cp usr share gitweb var www git 22 gt sudo cp usr lib cgi bin gitweb cgi var www git 30 1 gt ed var www git 31 gt In s usr li
5. Show the status 5 gt git status 6 Hide dirty files 7 gt git stash 8 Get the current master from upstream repository origin 9 gt git pull rebase origin master 10 Restore the locale configuration 11 gt git stash pop Now in order to be able to pull you need a clean working directory A pretty neat feature in git is the stash see git help stash which stashes the changes in a dirty working directory away See the command on line four of list ing 1 In this example the assumption is made that the current local branch is the master branch and it should be updated from a remote repository e g github com Listing 2 Output for git status On branch master 2 Changed but not updated 3 use git add lt file gt to update what will be committed 4 T use git checkout lt file gt to discard changes in working directory 5 T 6 T modified htaccess 7 modified db_script 8 modified robots txt 9 T modified typo3conf localconf php 10 111 no changes added to commit use git add and or git commit a 1 1 Getting started 3 Understanding pull A simple pull is a fetch followed by a merge In most cases that is not wanted and the rebase is the preferred method that is why that option is used on line eight of listing 1 It takes the other branch and attempts to put the current branch on top of it see git help rebase fora more detailed explanation
6. lt lt lt Updated upstream lt li class first item gt lt a href gt lt a gt lt li gt lt li class first item gt lt a href gt Home lt a gt lt li gt gt gt gt gt gt gt gt Stashed changes 2 2 Merge conflicts 11 I By editing the file by hand as shown in listing 17 the preferred version is restored Listing 17 Example of merge conflict resolved lt li class first item gt lt a href gt lt a gt lt li gt Alternatively because obviously our file is needed that version may be fetched as shown in listing 18 Listing 18 Example of merge conflict resolved alternative 1 gt git checkout ours FILE In another example a merge conflict has happened in on of the following files htaccess db_script robots txt or typo3conf localconf php listing 2 In order to keep the version that is running on the developing server and discard remote changes git checkout theirs FILE is used Mergetool After solving the conflicts or as a conflict resolution mergetool is run Basically when started it needs some resolution tool The default can be set in the gitconfig file in the users home directory In fig 2 2 a typical resolution Situation is shown The fig 2 2 shows the situation after the local file has been edited Saving the file and quitting all buffers will tell git the merge was successful If ours or theirs was checked out beforehand and the file therefore
7. stupid 1 Basics 1 1 Getting started The programme git itself and all the commands have help pages e g git help will show you the general and most commonly used commands The first one listed is git add This command like all other commands has its own help called by git add help Alternatively and maybe semantically more meaningful and faster git help add Choose whatever suites you best Literature A formatted and hyperlinked version of the latest git documentation can be viewed at kernel org There is also a gittutorial at kernel org and for more in depth introduction known as the Git User s Manual also at kernel org For offline as well as online read there is a book called Pro Git at progit org Another good online read is gitready com with many examples for beginner intermediate and advanced git users Most basic workflow before writing code First of all ensure the only dirty files in your typo3 instance whether local or remote are htaccess db_script robots txt and typo3conf localconf php They are required to be in git because they also might be point of failure on the live platform This is done as shown on line two in listing 1 section 1 3 The output 1 1 Getting started 2 should look like listing 2 Listing 1 Most basic example for getting started 1 Show the branch assume current branch is master 2 If not see branching how to checkout a branch 3 gt git branch 4
8. EWBRANCH and make it the current working branch 10 gt git checkout b NEWBRANCH 11 Practical examples 12 gt git branch werksfarbe_6790_htmlAndStylesheetClosedFunds 13 gt git checkout werksfarbe_6790_htmlAndStylesheetClosedFunds 14 gt git co b paddy_6789_123456_extension_vsp_ophirum Branch ex post Work on a different branch than the current but move the commits to the new working branch For example Move entire master branch to NEWBRANCH and rebuild the master from origin master afterwards Listing 8 Branch ex post The flag m means move branch master to NEWBRANCH 2 and do the corresponding reflog git help reflog 3 gt git branch m master NEWBRANCH 4 Get master from remote repository reset the commits 5 gt git checkout b master origin master A branch should consist of at least a single commit The rule is commit as often as possible Each commit must have a specific description of what the changes are which you can not leave empty Specific means Do not point out the obvious e g made changes this and that or are counterproductive because you could write that in all you commit messages regardless of what the commit was Mentioning that a commit has modifications is pointless That is what a commit 1 3 Branching and committing 7 is about namely Making changes in files Therefore specify what the changes were about and or why they were necessary
9. The more information a commit message has the better Listing 9 Commit 1 Commit a single file called FILE 2 gt git commit m A really good summary of what the commit is about Feel free to explain what changes are involved and why they where necessary Name people that suggested the changes FILE 31T Commit all files Use with caution 4 NB omitting the commit message leads git to open an editor 5 gt git commit a To make the review acceptable commit after each step of your work Having worked on subject A commit before you move on to subject B Commits must be made at latest after one hour of work on source files There should not be more than ten modified files in a commit An unlimited number of new files may be committed though Avoid forcing the reviewer to scroll unnecessarily when inspecting a commit Do not mix new files and modified files in one commit if it can be avoided It is better to make a commit for all new files and explicitly mention the fact that you added files or an extension in the commit message Correct a commit message NB Do not use the amend option after a push The option is like doing a reset HEAD 1 and git commit The commit will not be edited but made new But after a push there is still the old edit Without the force option there will be no chance of continuing This especially bad if somebody pulled in the meantime Listing 10 Correct a commit message 1 gt
10. VSP AG BORSIGSTRASSE 18 65 205 WIESBADEN GIT Richtlinien und Arbeitsprozess Datum May 29 2013 Erstellt von Patrick Emil Zorner CONTENTS i Contents List of figures H 1 Basics 1 LI DS ICE a ee eee Ore sm OU ALE A Bnd Gt ee GE Gn 1 Literatur abe ee eR eee ewe eh eee E eed 1 Most basic workflow before writing code 1 1 2 Adding moving renaming and removing 5 1 3 Branching and committing 5 Branch ex post 2 2 cdo goe a a nee a 6 1 4 Files in the git repository 1456S se bee eae ea ees 8 EE 6 A E EE or amp te WE ee E 8 2 Advanced 9 2 1 Restoring a branch from remote 9 AL Tee CORIO oe He N ER R ce td ee Pe OE a 9 Mergetgol 5 s 2 u OEMS EW OE SEES SE e SS RRS ES 11 2 3 Finding branches knowing the commit SHALI 13 ZA Toe tile oos ee Sw SSS SSE OSS HS Ee i 13 2 5 Make non git repository a git repository 15 2 6 Install a git public repository on debian 15 2 3 Garbage collecHOn 2 444544 0244 reteg en 17 e oe he RES EES EEE EEEE a 17 LIST OF FIGURES ii List of Figures 1 Diff view with base ours theirs and current file 12 2 Edited the file 000000000084 12 The aim of this pamphlet is not to be a tutorial but a lookup for common work flows best practices guidance etc So even copying and pasting a command from here ist not a gurantee that prevents anyone from doing something totally
11. b cgi bin gitweb cgi index cgi 32 gt sudo vim etc gitweb conf 33 8 lt 34 path to git projects lt project gt git 35 Sprojectroot var cache git 36 directory to use for temp files 37 Sgit_temp tmp 33 target of the home link on top of all pages 39 Shome_link Smy_uri 40 html text to include at home page 41 Shome_text indextext html 42 file with project list by default simply scan the projectroot dir 43 Sprojects_list Sprojectroot 44 stylesheet to use 45 Sstylesheet gitweb css 46 logo to use 47 Slogo git logo png 48 the favicon 49 favicon git favicon png 50 gt 8 51 gt sudo etc init d apache2 reload 52 gt cd var cache git 53 gt mkdir vsp ag 54 gt cd vsp ag 56 gt git bare init shared 5g Alternativly 2 7 Garbage collection 17 60 61 63 64 65 66 67 68 69 70 git init git config bool core bare true echo VSP AG amp Fondsvermittlung24 de gt git description git commit a touch git git daemon export ok git daemon base path var cache git detach syslog export all enable receive pack sv stop git daemon To stop the deaemon sv force shutdown git daemon git clone git git vsp ag vsp ag git clone ssh intern vsp services com var cache git vsp ag vsp ag 2 7 Garbage collection 2 git gc prune now Listing 24 Garbage collect
12. hose who prepare all the branches into a publishable shape and then push them out with a single command It is not appropriate for pushing into a repository shared by multiple users since locally stalled branches will attempt a non fast forward push if other users updated the branch This is currently the default but Git 2 0 will change the default to simple e upstream push the current branch to its upstream branch With this git push will update the same remote ref as the one which is merged by git pull making push and pull symmetrical See branch lt name gt merge for how to configure the upstream branch e tracking deprecated synonym for upstream e current push the current branch to a branch of the same name The simple current and upstream modes are for those who want to push out a single branch after finishing work even when the other branches are not yet ready to be pushed out If you are working with other people to push into the same shared repository you would want to use one of these To set the default push mode simply use git config Listing 5 Set push default gt git config global push default simple 1 2 Adding moving renaming and removing 5 It defines the action git push should take if no refspec is given on the command line no refspec is configured in the remote and no refspec is implied by any of the options given on the command line 1 2 Adding moving renaming and remov
13. ing To add a file to the git use git add FILENAME The Syntax to recursively add a directory is git add PATH DIRNAME When files are in the git repository it is more efficient to also tell git that these files moved have been renamed or removed Use the cached option to remove files from repository but not locally Listing 6 Removing 1 gt git mv SOURCE DESTINATION 2 gt git rm 3 gt git rm cached 1 3 Branching and committing It is useful to create a new branch if you work on a new project e g a bugtracker ticket number and or note identifier within this ticket and you are encouraged to do so The concept and principle is to divide and conquer It must always be possible to quickly find out which purpose a branch serves and who the owner is Therefore the branch name should look like this nickname_000_ _bugtrackerTicketNumber _noteNumber _description Creating a branch without a second argument will lead to HEAD being the base of the new branch that is the currently checked out branch Listing 7 Branching Lists all local branches marks the current working branch with a star 1 3 Branching and committing 6 2 gt git Branch 3 Create a new branch called NEWBRANCH 4 gt git branch NEWBRANCH 5 Make NEWBRANCH the current working branch 6 gt git checkout NEWBRANCH 7 Switch back to master branch 8 gt git checkout master 9 T Create a new branch called N
14. ion git gc aggressive 2 8 Prune
15. is not saved in editor vimdiff git asks you to confirm the merge success as shown in listing 19 2 2 Merge conflicts 12 5 Zeilen body 5 Zeilen body 5 Zeilen body padding H padding padding H a font family s OCAL 6234 css 1 1 Anfang lt BASE 6234 css 1 1 Anfang lt MOTE 6234 css 1 1 mM 5 Zeilen body padding a hover leae HEAD 5 Zeilen body 5 Zeilen body 5 Zeilen body padding padding padding color H color b color a hover i color font family s OCAL 6234 css 13 1 Alles lt BASE 6234 css 13 1 Alles lt MOTE 6234 css 13 1 5 Zeilen body padding a Figure 2 Edited the file 2 3 Finding branches knowing the commit SHA1 13 Listing 19 Closed the editor without saving 1 gt git mergetool 2 Merging 3 css css 5 Normal merge conflict for css css 6 local modified 7 remote modified 8s Hit return to start merge resolution tool vimdiff 9 4 Dateien zum Editieren 10 css css seems unchanged 11 Was the merge successful y n 2 3 Finding branches knowing the commit SHA1 Listing 20 Finding branches knowing the commit SHA1 git branch contains 864afa58a82c58e4367ac4e2b70b574667494a8c master git branch r contains 0fc352ba9abea4d9ec8de origin werksfarbe_0008632_umbau_der_tabs_auf_first_child 2 4 Config file Use thehelp config command to find out about all the settings
16. rce of ours and theirs Ours is the version in the remote repository github Theirs is the local version we are working on the developing server Listing 14 Merge conflict after pull rebase 1 Not currently on any branch 2 2 Merge conflicts 10 Unmerged paths use git reset HEAD lt file gt to unstage use git add rm lt file gt as appropriate to mark resolution both modified FILE NB during rebase the HEAD got detached see above output gt git branch no branch master The stages of a file and their content may be displayed as shown in listing 15 from left to right there are file permissions the SHA1 the stage and the filename of the file N w K wn a x In Listing 15 List file status gt git ls files s FILE 100755 b42be60e564a0f9a948408637fec6ec603793d7e 1 FILE 100755 2c3b3cac7dc0275c073edaae7cee5dd90c90f210 2 FILE 100755 8bfle221687ce7ec48b180a2f0880239ce34455b 3 FILE View the FILE in the different versions gt git show 2c3b3cac7dc0275c073edaae7cee5dd90c90 f210 ours gt git show 8bf1e221687ce7ec48b180a2f0880239ce34455b theirs listing 16 listing 17 we see an example how you can hand merge a file that is stale locally Home is still present in their file but already has changed in the remote origin Home has been removed in our file a Listing 16 Example of merge conflict lt lt lt lt

Download Pdf Manuals

image

Related Search

Related Contents

  Digitus DS-11402-1 KVM switch  

Copyright © All rights reserved.
Failed to retrieve file