Day-08 & 09 Git-Terraform-AWS

Mokadi Surya Prasad
5 min readOct 5, 2024

--

git merge:

Git merge is a command used in Git to combine changes from two different branches into one branch. It allows you to integrate the work done on one branch into another branch.

Now, we are creating a new branch called dev. This branch will include all the previous commits from the master branch. To do this, we will first create the dev branch and then switch to it.

Now, we can see that in the snapshot, the commits from the master branch are represented as the first stage. This means all the previous work and commits that were made in the master branch are included there.

On the other hand, the commits in the dev branch are shown as the second stage. This indicates that the dev branch started with all the commits from master, and any new work or changes made in the dev branch will appear as additional commits after the initial commits from master.

Now we can see again I'm adding new files in master branch.

Now we can I am merging the files dev to master branch.

Now we can I am merging the files master to dev branch.

Now we can see the master branch last commits was added in dev branch.

git rebase:

Git rebase is a command used in Git to move or combine a sequence of commits to a new base commit. It allows you to integrate changes from one branch into another while maintaining a linear project history.

Now I'm adding the files into rebase-example master branch.

Now I’m adding the files into rebase-example dev branch.

Now we can see I added the new files into master branch.

Now I'm moving to dev branch, now we can see the files order in the below snapshot.

Now, we can see that there are no commits labeled 6 to 11 in the dev branch before entering the rebase command. However, after entering the git rebase command, all the commits from the master branch have been added to the dev branch.

Now we can move to master branch then we can see how it’s happens after entering the git rebase dev command.

We can see that the development commits are now added at top of the master branch commits. Previously, the dev commits were not included on top of the master commit 11.

These commands rewrite the previous commit history.

git stash: Git stash is a command used in Git to temporarily save changes that you have made in your working directory but do not want to commit yet. It allows you to switch branches or perform other tasks without losing your uncommitted changes.

Now, I’m working on the app.js file, but suddenly my manager gives me a task to work on app.py. To handle this, I can use the following command to temporarily save my changes in app.js:

git stash

This command saves my current work in app.js so I can switch to another task without losing my progress. After I finish working on the app.py file, I can return to my app.js work by using:

git stash pop

This command brings back my saved changes in app.js, allowing me to continue where I left off.

git reset: Git reset is a command used in Git to undo changes in your Git repository. It allows you to move your current branch pointer (HEAD) back to a previous state, affecting the commit history, the staging area, and the working directory. There are three main types of resets: soft, mixed, and hard.

git reset — soft:

Now, when I enter the git reset --soft e53925b command, the e53925b commit becomes the top of the HEAD commit, and the previous commits are removed. The advantage of this command is that no files are deleted; the file list remains unchanged.

git reset — hard:

Now, when I enter the git reset --hard 5ae3464 command, the 5ae3464 commit becomes the top of the HEAD commit, and the previous commits are removed. The downside of this command is that all changes are deleted, and the file list is changed.

Git Secrets:

Git Secrets is a tool that helps you prevent sensitive information (like passwords, API keys, and private data) from being accidentally committed to your Git repositories. It acts as a safeguard to maintain the security of your code and data.

--

--

Mokadi Surya Prasad
Mokadi Surya Prasad

No responses yet