Recently, I decided to dive deep into Git and GitHub, two essential tools for any one looking to get into the Cloud. Following this tutorial, I set up repositories, managed changes, handled merge conflicts, and more. Here’s a concise recap of my experience and the commands I used.
Setting Up a Local Repository
The first step was creating a local repository using Git:
- Configured Git: git config –global user.name, git config –global user.email
- Initialized a new Git repository: git init
- Checked the status and listed files: git status git ls-files git ls-files -s

Managing Files
I added, removed, and moved files using Git commands:
- Adding files: git add <file>
- Removing files: git rm <file>
- Moving/renaming files: git mv <file>

Ignoring Files with .gitignore
I created a .gitignore file to prevent tracking certain files:
*.txt

Committing Changes
I committed my changes and learned various commit commands:
- Committed staged changes: git commit -m “Initial commit”
- Committed without staging: git commit -a -m “Commit message”
- Amended the last commit message: git commit -m “New message” –amend

Viewing Logs and Differences
To view commit logs and differences, I used:
- Basic log: git log
- One-line log: git log –oneline
- Detailed differences: git log -p
- Graphical log: git log –graph –oneline –decorate –all

Branching and Merging
I created, switched, merged, and deleted branches:
- Creating and switching branches: git branch <name> git switch <branch name> git switch -C <branch name>
- Merging branches: git merge -m “Merge message” <branch name>
- Deleting branches: git branch -d <branch name>

Remote Repositories
I added a remote repository and pushed changes:
- Adding a remote repository: git remote add origin https://github.com/PhysioFred/LearningGitwithCookie.git
- Viewing remote repositories: git remote -v
- Pushing changes: git push -u origin main

Handling Merge Conflicts
I purposely created merge conflicts and resolved them:
- Fetching and rebasing: git fetch git rebase origin/main
- Merging and rebasing: git merge origin/main git rebase -i –root
Using GitHub Tokens
To interact with GitHub securely, I created GitHub tokens and authenticated my CLI actions.
Summary
Following the tutorial was a fantastic way to get hands-on experience with Git and GitHub. From creating a local repository and making changes to handling merge conflicts and pushing my code to GitHub, I learned a lot. This journey has been instrumental in understanding version control, and I’m excited to apply these skills in my future projects.
If you’re learning Git and GitHub, I highly recommend following the tutorial I used. Happy coding! 😄
If you want to see my repo you can go here: https://github.com/PhysioFred/LearningGitwithCookie

FAQs
- What is Git? Git is a version control system that helps you track changes to your files and collaborate with others.
- What is GitHub? GitHub is a web-based platform that uses Git for version control and allows you to host and manage your code repositories.
- How do I resolve merge conflicts in Git? You can resolve merge conflicts by fetching the latest changes, rebasing your work, and using a conflict resolution tool like VSCode.
- What are GitHub tokens? GitHub tokens are used to authenticate your identity when interacting with GitHub from the command line.
- Why should I use a .gitignore file? A .gitignore file tells Git which files or directories to ignore, preventing them from being tracked and pushed to your repository.

Here is a list of all the commands I used for this project:
git config –global user.name <username>
git config –global user.email <email>
git init
git status
git ls-files #list files
git ls-files -s
git add <file>
git rm <file>
git mv <file> #basically do normal commands and add git before it
git ignore
git restore
git commit
git commit -a -m “<message>” #commit without staging
git commit -m “<new message>” –amend #amend last log
git log
git log –oneline
git log -p # shows us the differences between commits
git log –graph –oneline –decorate –all
git reset <hastag git log number> #
git rebase -i –root
git branch
git branch <name>
git branch -M <current branch to have a new name> #-M for move or rename
git switch <branch name>
git switch -C <branch name> #-C creates a new branch
git merge -m “<message” <branch name want to merge>
git branch -d <branch to be deleted>
git remote -v
git remote add <remote place> <URL link>
git config -l #list credentials and push/pull repo and origin
git push <remote list> <repo url>
git merge origin/main
git rebase origin/main
gh repo view