What is git?

Open source and free Source Control Management – SCM. You can manage changes to files over time. Download for your system. Use gitbash to control. Other command line tools can be used.

Configure git

Specify name and email address – so git knows who is doing stuff

    Specify default branch name – (this was done in the installation too)

      Initialise Repository

      there will now be a hidden file in the folder – .git

        git Status

          All the files are untracked

            Track a File

              Unstage a file (stop tracking)

                Ignore files

                • create new text file called .ignore
                • insert files you want to ignore

                Commit

                Takes a snapshot of the repository

                  Changes to files

                  If you change a file git will recognise this

                    To see the difference

                      Environments

                      • Working Files
                      • Staging
                      • Commit

                      Add/remove modified file to ‘snapshot’

                      Places this file into Staging where it will stay until we are ready to commit

                      This will remove the file from Staging

                        Bypass Staging

                        Commits all

                          Restore a file

                          You could delete a file from the folder and then git status would show

                            We can then restore this file with

                              Change filename

                              Use mv

                                git Log

                                    Amend Commit

                                      Reset to Previous Commit

                                        Rebase

                                          Branches

                                          • A copy of your main branch which you can edit and then merge once you are satisfied with the changes
                                          • Used a lot in coding development

                                          Create New Branch

                                          creates new branch

                                          shows branches

                                            switches to this branch

                                              Merge branches

                                                Delete Branch

                                                  Merge Conflicts

                                                  • if you change the main branch whilst the fixbug branch is also edited you encounter a conflict when you try and merge them

                                                  Set Up github Account

                                                  Create Cloud Repo

                                                  • Create a new repository
                                                  • Give it a name
                                                  • Public/Private – depends on who you are working with
                                                  • Create repository

                                                  Push Existing Repo

                                                  We already have a repository on our local computer. github gives it the commands for pushing it to the cloud.