-
Navigate to project folder:
cd /path/to/your/project -
Initialize Git repository:
git init
-
Add remote repository:
git remote add origin https://github.com/YourUsername/your-repository.git
-
Add files to staging:
git add . -
Commit changes:
git commit -m "Initial commit message" -
Push to GitHub:
git push -u origin master # Or 'main' if your GitHub repo uses main branch
-
Navigate to project:
cd C:\Users\amnic\OneDrive\Desktop\Coding\Git\ProjectName
-
Initialize and stage:
git init
git add .git commit -m "Initial commit of ProjectName" -
Configure remote:
git branch --unset-upstream
git remote -v
git remote set-url origin https://github.com/YourUsername/your-repository.git
-
Push and update branches:
git push -u origin master
git branch -m master main
git fetch origin
git push -f origin main
git push origin --delete master
-
Get the HTTPS URL from GitHub repository
- Go to repository on GitHub.com
- Click green "Code" button
- Copy the HTTPS URL
-
Navigate to desired directory
cd your/desired/directory -
Clone the repository
git clone https://github.com/YourUsername/your-repository.git
-
Enter the project directory
cd your-repository
-
Navigate to repository:
cd /path/to/your/project -
Create backup branch:
git checkout -b backup-main
-
Return to primary branch:
git checkout master # or 'main' depending on your branch name -
Clean repository history:
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch PATH-TO-FILE" --prune-empty --tag-name-filter cat -- --all -
Force push changes:
git push origin --force --all
This process rewrites repository history to remove sensitive information from previous commits while preserving current code.
-
Rename local branch to main:
git branch -M main
-
Pull remote changes with unrelated histories:
git pull origin main --allow-unrelated-histories
-
Push changes to main branch:
git push -u origin main
This process synchronizes repositories when working across multiple machines and resolves branch naming conflicts.
-
Remove file and stage deletion:
git rm filename
-
Commit the removal:
git commit -m "Remove file" -
Push changes to remote:
git push origin main # or master depending on branch name
-
Create backup of original files (optional):
cp file1.md file1_backup.md cp file2.md file2_backup.md
-
Edit files with new content
-
Stage and commit changes:
git add . git commit -m "Reorganized file contents"
-
Push to remote:
git push origin master
-
Check remote repository status:
git remote -v
-
Fetch latest changes:
git fetch origin
-
Pull changes from remote:
git pull origin main
-
Pull with specific options:
git pull --rebase origin main
-
When Vim appears (usually during merge operations):
- You'll see a text editor interface with merge message
- Cursor will be at the top of the file
-
Basic Vim commands for editing:
i # Enter insert mode (allows typing)Esc # Exit insert mode:wq # Save and exit (write and quit):q! # Exit without saving (quit without write)
-
Common workflow:
- Press 'i' to enter insert mode
- Type your merge message
- Press 'Esc' to exit insert mode
- Type ':wq' and press Enter to save and exit
This process handles the Vim editor that appears during Git merge operations or when Git needs a detailed commit message.