- Run the command
git --version
- If there's an error, install Git Bash
- Choose default options, but override the branch name with main.
- Reload VS Code to apply changes.
- Run the command
gh --version
- If there's an error, install GitHub CLI
- Choose default options.
- Reload VS Code to apply changes.
- Run the command
git config user. name
. - If it's not correct, run the command
git config user. name "myUserName"
.
- Run the command
git config user.email
. - If it's not correct, run the command
git config user.email "[email protected]"
.
1. Open GitHub.
2. Open the repository.
3. Click on the green Code button.
4. Copy the HTTPS link.
git init
git remote add origin https://github.com/myRepositoryLink
git pull origin main
- If there are files that VS Code doesn't need (like Glitch files), delete those.
- Click on the cat icon at the top left.
- Click on the green new button at the top left.
- Enter the repository name.
- Click Create repository.
- Do not change the default settings.
gh auth login
git remote set-url origin https://github.com/myRepositoryLink2
git add .
git commit -m "added files"
git push --set-upstream origin main
git add .
git commit -m "the changes I made"
git push
git branch -M main
git config --global init.defaultBranch main
ls -a
rm -r .git
ls-a
= List ALL files and foldersrm -r.git
= removes entire directory/folder (becomes hidden)
git init
- Initializes source control
git pull origin main
- Copies files from the origin
gh auth login
- Grants authorization to push to your repository
git remote set-url origin
- Sets the origin
git push --set-upstream origin main
- Pushes files to GitHub and makes origin and main the default options
git branch
- Views the branches
- Run the command
git init
. - Run the command
git config user.name
. - If it's not correct, run the command
git config user.name "myUserName"
.
gh auth login
git remote set-url origin https://github.com/myRepositoryLink2
git add .
git commit -m "added files"
git push --set-upstream origin main
- Run the command
git init
. - Run the command
git config user.email
. - If it's not correct, run the command
git config user.email "[email protected]
.
- Run the command
git init
. - Run the command
git config --global user.email
. - If it's not correct, run the command
git config --global user.email "[email protected]
.
Force delete repository
git add .
git commit -m "description of changes"
git push
rm -rf .git
git branch
git branch branchName
git switch branchName
git checkout myBranch
- Switch to the branch that will absorb the changes. Example:
git switch main
git merge [branchName]
INITIALIZE SOURCE CONTROL
git init
touch index.html
git add .
git commit -m "added files"
- GITHUB: Create a new repository called merge-test
git remote add origin https://myRepository
PUSH TO A NEW REPOSITORY
git push --set-upstream origin main
git branch myBranch
git switch myBranch
- add
<p>Hello World!</p>
to the index.html file - Save the changes CTRL + S
git add .
git commit -m "updated file
git switch main
- Change the history from
Auto
toAll
MERGE THE BRANCH
git merge myBranch
git push
git switch myBranch
- Add
<p> Amazing World!</p>
to index.html file
SETUP FOR REBASE
- Save the changes CTRL + S
git add .
git commit -m "updated file"
git switch main
- Add the file about.html with
touch about.html
git add .
git commit -m "added a file"
git merge myBranch
- Approve the merge by closing the merge editor
REBASE THE COMMITS
git rebase myBranch
git push
git switch myBranch
git rebase main
CORRECT A MERGE CONFLICT
- Add to about.html
- Save the changes CTRL + S
git add .
git commit -m "added heading"
- git switch main
- Add to about.html
- Save the changes CTRL + S
git add .
git commit -m "added heading"
git merge myBranch
//creates a conflict- Select a resolution.
- Save the changes CTRL + S
git add .
git commit -m "merged changes"
git push
//fixed a merge conflict
CORRECT A REBASE CONFLICT
git rebase myBranch
- Select a resolution
- Save the changes CTRL + S
git add .
git rebase --continue
git push
//will result in an errorgit push --force
RESTORE A SAVE POINT
- Select a commit to restore.
- Copy its id.
git reset--hard id123456789
git push
git push --force