Manipulating History Contd
Git rebase interactive
- Using this interactive rebasing we can manipulate history
- Lets create a repository and then have the following commits

Activity 1: Need to fix the commit message

* Lets rewrite history in this case i would use HEAD~4
git rebase -i HEAD~4

* During interactive rebase most common actions which we perform are
* pick => add the commit during the rebase as it is
* squash => meld this commit into previous (combining two commits into one commit )
* edit: stops and edits the commit
* drop: removes the commit
* reword: change the commit message
* Now since we need to change the commit message




Activity 2: Lets change the typo in the first commit contents
- typo:

- So lets rebase interactively
git rebase -i HEAD~4





Activity 3: Lets combine the second and third commit into one commit
- History:

- Command would be
git rebase -i HEAD~3


Activity 4: Lets drop the fourth commit
- History

- command
git rebase -i HEAD~1


Exercise:
- Create a repository and ensure you have 3 commits
first
second
third
- Do the rebasing to
- combine second and third commit as one commit
- change the commit message of first commit to “Primary Commit”
- solution:


Collaboration in Git
- When we work on code for an application, there will be multiple developers working on the source code, so working in local repository is not an option.
- We need a connectivity with some Git Server (git + daemon (connectivity and user management))
-
Fourth Area of git
-
Lets create the accounts in the following Hosted Git Servers
- GitHub Refer Here
- BitBucket Refer Here

- AzureSourceRepos Refer Here
- AWS Code Commit

Public vs Private Repositories
- Most of hosted repositories gives two options
- Public Repository:
- Every one can read the contents (source code)
- This is apt for open source.
- Generally for others to contribute we have two options
- providing write access
- pull requests
- Private Repository
- Read permissions/write permissions will be given to dedicated users
- Apt for Enterprise Users.
- Public Repository:
Authentication to Remote Git Repositories
- Using Personal Authentication token
- Using an SSH key (* my favorite)
- Using your Hosted Git password and username (2-factor authentication)
Creating a keypair
- Execute
ssh-keygen

Activity 1: Make your local repository sync with Remote Repository
- You are first person to create this project, so you created locally, Now you need to make it available to other developers
- Git Authentication Mechanisms for Remote Repositories
- Create a Remote Repository:
- GitHub:


- BitBucket:


- Azure Source Repos: Create a repository as shown in the class
- GitHub:
- Every repository will have a url
- Azure Source Repos:
- Https: https://shaikkhajaibrahim.visualstudio.com/Projects/_git/qtecommerce
- SSH: shaikkhajaibrahim@vs-ssh.visualstudio.com:v3/shaikkhajaibrahim/Projects/qtecommerce
- GitHub:
- Https: https://github.com/GitPracticeRepo/qtecommerceapr.git
- SSH: git@github.com:GitPracticeRepo/qtecommerceapr.git
- BitBucket:
- Azure Source Repos:
- To add a remote to your local repository
git remote add <remote-name> <remote-url> - The default remote-name is
origin - Lets add the remote for github


- To send all of the commits from local to remote we use
git push <remote-name> <branch>




- Remote for bitbucket


- Remote for Azure Source Repos:

- Sending one more branch

- Git tries to maintain a remote branch for every branch pushed into remote repository

