--- ## βœ… GIT ADD ., GIT COMMIT, GIT PUSH CHEAT --- ## πŸ”§ Option A ### 🧱 Step 1: Create Your Script 1. Open a terminal. 2. Run this to create the script file: ```bash nano push ``` 3. Paste the following content: ```bash #!/bin/bash # Check if a commit message is provided if [ $# -eq 0 ]; then echo "❌ Usage: push \"your commit message\"" exit 1 fi # Combine all arguments into one commit message commit_message="$*" echo "πŸ“ Staging changes..." git add . echo "πŸ“ Committing changes..." git commit -m "$commit_message" echo "πŸš€ Pushing to remote..." git push echo "βœ… Done!" ``` 4. Save and exit: * Press `CTRL+O`, then `ENTER` to save. * Press `CTRL+X` to exit. --- ### πŸ” Step 2: Make the Script Executable Run: ```bash chmod +x push ``` --- ### πŸ“‚ Step 3: Create a Local Bin Directory (if it doesn’t exist) ```bash mkdir -p ~/.local/bin ``` --- ### 🚚 Step 4: Move the Script to Your Local Bin ```bash mv push ~/.local/bin/ ``` --- ### πŸ› οΈ Step 5: Add `~/.local/bin` to Your PATH #### Check if it's already in your PATH: ```bash echo $PATH ``` If not, do the following based on your shell: ## To know your which shell you're using use ```bash echo $SHELL ``` #### If you're using **Bash**: ```bash echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` #### If you're using **Zsh**: ```bash echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc ``` --- ### βœ… Step 6: Test It! Go to any Git-tracked folder and run: ```bash push "your commit message here" ``` You should see: ``` πŸ“ Staging changes... πŸ“ Committing changes... πŸš€ Pushing to remote... βœ… Done! ``` --- ## πŸ”§ Option B (Recommended): Use a Shell Alias let’s enhance your workflow by: 1. βœ… Creating a script that also shows `git status` after push 2. βœ… Creating a global **alias** named `push` so you don’t have to move or chmod anything manually. --- ### 🧱 Step 1: Create the Bash Function Alias Open your shell config file: * For **Bash**: ```bash nano ~/.bashrc ``` * For **Zsh**: ```bash nano ~/.zshrc ``` ### 🧩 Step 2: Add This Function Alias Paste this **at the bottom** of the file: ```bash function push() { if [ $# -eq 0 ]; then echo "❌ Usage: push \"your commit message\"" return 1 fi local commit_message="$*" echo "πŸ“ Staging changes..." git add . echo "πŸ“ Committing..." git commit -m "$commit_message" echo "πŸš€ Pushing to remote..." git push echo "πŸ“Š Status:" git status echo "βœ… Done!" } ``` ### πŸ”„ Step 3: Apply Changes ```bash source ~/.bashrc # or ~/.zshrc ``` --- ### βœ… Step 4: Use It Anywhere From any Git project directory: ```bash push "updating README with new section" ``` replace "updating README with new section" with your commit message --- ## 🧠 Summary of What This Does: * βœ… Adds all changes: `git add .` * βœ… Commits with your message * βœ… Pushes to the current branch * βœ… Displays `git status` to confirm what’s left (if anything) --- ---