The command to add files and directories is similar as git diff meaning you can add multiple file and directory paths to define which ones should be added: git add index.php lang-directory file2 Any added file will be included in your next commit. So far these files are "unstaged" and once you add files then these will be "staged". Once you are satisfied with the changes git diff shows you, you can add those files so they can be committed and pushed. If you only want to see changes for a specific file or directory then you can list multiple files or directories as arguments like git diff file1 file2 dir1. To see what you changed in these files you can execute the command git diff. You will first want to execute git status to see which files have been modified. It's good to commit and push regularly (at least daily) even if a feature is not finished yet, so you always have a backup if changes get lost for some reason. Adding, committing and pushing codeĪfter you added or modified a few files, you will want to push these changes to the remote repository. Instead of git checkout -b you can also use git switch -c if you are using a newer version of git. The checkout command will create a new branch if the -b option is supplied, otherwise it will try to load an existing branch. Otherwise, if you don't specify the base branch and you are already in another branch that has changes, then it would copy all changes from the current branch into the new branch. This way it will create a new branch from the 5.x-dev branch. For example: git checkout -b bugfix 5.x-dev. For Matomo for WordPress this would be develop. This is for example *.x-dev when working on Matomo On-Premise ( 5.x-dev is the main branch at the time of writing this). Where you need to replace $MAIN_BRANCH with the current main branch. To add a new branch, run the following command: git checkout -b bugfix $MAIN_BRANCH Ideally, the branch name is not just a pure number as it might cause a collision with a commit hash (explained below what this is) and git wouldn't know if it should check out a branch or a commit. It's not a requirement though, since the branch will only exist temporarily and the related issue will contain all the needed details. Optionally, a descriptive name can be added to the branch name if wanted. matomo-1111 or if it's a Jira issue then e.g. The branch name ideally always contains the GitHub issue number e.g. This allows you to create a pull request from this branch later which can then be reviewed. Creating a new branchīefore you start coding on a new feature, you should make sure to keep your changes separate from the main branch. This clones the Matomo repository into a matomo directory, initialises all submodules and pulls all the screenshot testing files using LFS. You will always want to use SSH URLs when cloning a repository, for example clone a repository, use for example: git clone matomo GitHub supports cloning via HTTPS and SSH URLs. If you cloned the repository without having Git LFS installed then follow these instructions. As often there is no right or wrong and not one way to do something. If you prefer using Git through your IDE like PHPStorm, or if you are more accustomed to use a slightly different commands or methods then please go with your preferred option of what you feel comfortable with. Below are some tips for using git along with a guide for how we work using git on the command line. At Matomo we're using Git version control system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |