This will resolve all your git and github starting errors for Beginners and people facing errors
Copyright Disclaimer under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favour of fair use."
Git error resolving sheet :
Git Problem of too many changes
rm -rf .git //This command can be used to delete a initalized git repo on your local macine
How to push files using git to your Github 2022
git init
git add . //To add all the files in the folder
git commit -m 'first commit' //-m tells you the message that has to be put
git remote add origin Remote repository url
some cheat codes
ls -a is a command you can use on git bash to view all hiden files in a folder
touch 'filename.txt' to create new file in a folder using git
git status // gives us the untracked files which are not added to our repo and not commited yet
git add name.txt to add a particular file to your repository not all
vi name.txt to do some changes in the files right from bash
git restore --staged names.txt to not commit or not stage the change
git log to see history of changes
git fetch --all --prune this command will fetch all changes that had happended to main branch //prune are the ones that are deleted will also be fetched.
git pull upstream will also do the same thing.
git reset --hard upstream/master this will reset main or master branch of your origin to main or master branch of upstream .
If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:
git pull --rebase
git push
The full syntax is:
git pull --rebase origin main
git clone to clone a repo from github to your desktop
From where you have forked the project is known as Upstream url we use git remote add upstream url
Always create a new branch whenever commiting to someone other project
git branch akash
git checkout akash will switch you to this branch
you can directly create a new branch and switch to it using command git checkout -b akash //-b specifies the branch name
How to merge code from your new branch to main Branch from where you forked ?
Firstly you need to push the changes or commit to your forked copy or the origin and as you do so , When you will go to your forked github repo you will se an option for create pull request to merge click on it and thats it , If the owner of the repo merges then it your code get merged to main branch.
#git #github #vscode
#tutorials #errors #start