Gid add: track changes
Git commit: commit changes
Git push: git push origin main
Git status
Ssh keys git remov
New git repository:
Git init
Git add
For modified files: Git add and commit: git commit -am <message>
Git commit
Git push: get error(create connection)
Git remote add origin <git repository url>: add reference
Git remote -v: shows remote rep connect
Git push –u origin main
upstream(default location)
Git branching
Master branch(default)
Feature branch
git branch
Create new branch: git checkout -b <name of branch>
Change branch: git chechout <branch name>
Compare two versions of code: git diff <branch name>
Merge changes: git merge <branch name to merge to>
Get a message of no upstream branch
Solution: git push -u origin <branch name>
Pull request
Undoing commits
Unstaging previous commits: git reset/ <name of file to ustage>
Unstaging pushed commit: git reset HEAD~1(pointer to last commit,~1, last commit)
To view all commits: git log
To unstage to a specific commit: git reset <#commit>
To completely remove commits(not just unstaging): git reset –hard <#commit>
Fork repos
Common errors:
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to
'[Link]
hint: Updates were rejected because the tip of your current branch is
behind
git pull origin main
git pull origin main.
git pull origin main
● branch main -> FETCH_HEAD
fatal: refusing to merge unrelated histories
git merge --allow-unrelated-histories origin/main
git push origin main