How to Handle git pull with Local Changes on AWS

When working with Git on an AWS environment, you might encounter a situation where you need to pull updates from your remote repository, but you also have uncommitted local changes. This tutorial will guide you through three scenarios to handle this situation effectivel


Scenario 1: Keeping Your Local Changes

If your local changes are important and need to be preserved, follow these steps:

1. Stage Your Changes

Use git add to stage all your local changes:

git add .

2. Commit Your Changes

Commit the staged changes with a meaningful message:

git commit -m "Describe your local changes here"

3. Pull Updates from Remote

After committing, pull the latest changes from your remote repository:

git pull origin main

If there are conflicts, Git will notify you. Resolve conflicts manually, then continue with:

git add .
git commit -m "Resolve merge conflicts"

4. Push Your Changes

Once resolved, push the combined changes to the remote repository:

git push origin main

Scenario 2: Discarding Your Local Changes

If your local changes are unnecessary and can be discarded, follow these steps:

1. Discard Unstaged Changes

To discard changes that haven’t been staged:

git restore .

2. Unstage Any Staged Changes

If any changes were staged with git add, unstage them:

git reset
git restore .

3. Pull Updates from Remote

Now, safely pull the latest changes:

git pull origin main

Scenario 3: Temporarily Saving Your Local Changes

If you’re unsure about keeping or discarding your changes, you can stash them temporarily:

1. Stash Your Changes

Stash your local changes to save them temporarily:

git stash

2. Pull Updates from Remote

Pull the latest changes after stashing:

git pull origin main

3. Apply Stashed Changes

Reapply your saved changes from the stash:

git stash apply

Tips for Best Practices

  1. Use a .gitignore File
    To avoid unnecessary files like .pyc or build files from being tracked, always set up a .gitignore file in your repository. Example .gitignore: *.pyc node_modules/ .env
  2. Test Changes Locally
    Before pushing local changes, test them thoroughly in your AWS environment.
  3. Communicate with Your Team
    If working in a team, communicate about your changes to avoid conflicts during git pull.

Conclusion

Managing local changes while pulling updates from a Git repository is a common scenario for developers working on AWS or any remote server. By following the steps in this guide, you can handle local changes confidently and avoid issues like merge conflicts.

Feel free to share your experiences or questions in the comments below!


How to convert AWS .pem key to putty .ppk key

Here I have AWS key .pem , to connect with putty in windows we need the .ppk format ,so here i have to convert AWS .pem key to putty .ppk key ,in simple have to convert .pem to .ppk

How convert AWS .pem key to putty .ppk key for that we have lots of software available, here am going to show with the help of  PuTTYgen

1 Download .pem (Privacy Enhanced Mail) from  AWS , is a base64 container format for encoding keys and certificates

 

2 ) Download PuTTYgen from online and install

 

3) Open PuTTYgen

convert AWS .pem key to putty .ppk key

4) Click Load button and load the .pem files

convert AWS .pem key to putty .ppk key

5) Click “save private key ” button and save your ppk files

so you converted AWS .pem key to Putty Private Key(ppk) or in simple .pem to .ppk

How to setup two domain using Lamp or XAMPP AWS Linux 2

Suppose we need to create two domain with xampp Let say tutorialshore.com and viewshore.com

First we have to install xampp in your AWS Linux 2  see below link for that

How to install xampp and FTP in AWS Linux 2 server

Then folle below steps

1 Allow custom virtual hosts from Apache config


open Apache config file using below command

# vi /opt/lampp/etc/httpd.conf

 

Find out below code
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf

Replace above code with 

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

 

2) Add custom domain in the hosts file

#vi /etc/hosts


127.0.0.3	tutorialshore.com
127.0.0.5	viewshore.com



3) Add custom domain in the hosts file

#vi /etc/hosts
 
add this two host at the end

127.0.0.3	tutorialshore.com
127.0.0.5	viewshore.com

4) Create your virtual hosts

#vi /opt/lampp/etc/extra/httpd-vhosts.conf

Add below line at the end


<VirtualHost 127.0.0.3:80>
 DocumentRoot "/opt/lampp/htdocs/tutorialshore"
 DirectoryIndex index.php

 <Directory "/opt/lampp/htdocs/tutorialshore">
 Options All
 AllowOverride All
 Require all granted
 </Directory>
</VirtualHost>

<VirtualHost 127.0.0.5:80>
 DocumentRoot "/opt/lampp/htdocs/viewshore"
 DirectoryIndex index.php

 <Directory "/opt/lampp/htdocs/viewshore">
 Options All
 AllowOverride All
 Require all granted
 </Directory>
</VirtualHost>
  



5) Create project Directoty

#cd /opt/lampp/htdocs
#mkdir tutorialshore
#mkdir viewshore

6) Upload your files and enjoy with your two new website