#Create a directory first then run# git init Set up intial files for Master branch ---------------------------------------------------------------------------- gedit file_a #Create file# git add file_a #add to traceked files# git commit -m 'intial commit' #Commit changes to brach# #Tells git tat the upstream branch of the local branch is the master branch then it pushed the commits to the master branch# git remote add origin https://github.com/USERNAME/REPO-NAME.git git push --set-upstream origin master Create more files and push to master --------------------------------------------------------------------------- gedit file_b #Create more files# gedit file_c #Create# git ls-files #check that the master branch files exist in the new branch# Git add -A #Add all the new files to git tracking# git commit -m 'second commit' #Commit all the new chnages# git log # Use git log to see the histroy so far# git status #If you check you can see that you are ahead of origin/master# git push #Push the chnages to remote (master)# Creat branch and make feature changes ------------------------------------------------------------------------------ #This assumes that your local master is up to date# git checkout -b exmp1 #Create new branch exmp1# gedit file_a #edit the file and add more "Hello world" lines# gedit file_d #Another new file# git add -u #Update the modified file so that have already been tracked# git commit -m '3rd commit, I modified a file and created a new one' #Commit the new changes and write a meesage# git push -u origin exmp1 #Create a new remote branch and push the local update branch to it# ------------------------------------------------------------------------------ Create Pull request and merge on GitHub ------------------------------------------------------------------------------ Demonstrating git reset (hard-DANGER!, mixed-safe) ------------------------------------------------------------------------------ git checkout exmp1 #Change to exmp1 branch# gedit file_B #Edit file_B, add more "Hello world" lines# git add -u #Update the modified file so that have already been tracked# git reset --mixed #Resets to the last commit. All changes to old and new files are unstaged i.e you need to excecute git add to stage them again.# git add -u #Update the modified file so that have already been tracked# git reset --hard #Resets to the last commit. All changes to old and new files are discarted# git branch -a #List all branches local, and remote# (Create ( ͡° ͜ʖ ͡°) and ) Resolve conflicts ------------------------------------------------------------------------------ git checkout master #Change back to master# git checkout -b conflict_demo #Create an new branch and change to it# gedit file_B # Modify file_B (add a new word to the line)# git add -p #Option to add or remove modifications# git commit -am 'Modified file_B' #Add and commit the new changes with a meesage# git push -u origin conflict_demo #Create a new remote branch and push the local branch to it# git checkout master #Change back to master# git chekcout -b conflict_demo2 #Chencout a new branch to create a conflict# gedit file_b # Edit the same lines of file_b as we did for conflict_demo branch# git add -u git commit -m 'Edited same line in file_b' git push -u origin conflict_demo2 Merge new branch with master and push ------------------------------------------------------------------------------ git checkout master #Change back to master so that you can pull the changes# git pull #IMPORTANT-> Pull from master to make sure local is up to date# git pull origin conflict_demo #Marge conflic_demo into master# ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ git checkout master #Change back to master so that you can pull the changes# git pull origin conflict_demo2 #Merge conflict_demo into master# cat file_b #Check the file for the conflict markings# git diff #Another command to display modifications and conflicting lines# git reset, git merge --abort, #General action to take when confilcts arise i.e merging git merge --abort# gedit file_b #Edit file_B to resolve the conflict# #Commit the eddited file to finish the process# git commit -am 'file_B conflict resolved' Git rebase ------------------------------------------------------------------------------ git checkout exmp1 git diff master exmp1 git pull --rebase origin master Clone repository ---------------------------------------------------------------------------- #git clone https://github.com/username/the_repo git clone https://github.com/USERNAME/REPO-NAME.git cd git-work-flow git checkout --track origin/example # Clone remote branch to local.#