Github Basics
- git init
- git branch -m "main"
- git add .
- git commit -m "first commit"
- git push -u origin main
- elements in bold being most common
Comments
- Working tree, staging (index), history are the 3 components of a subversion system. These components are synonymous to present, future and history
- git init makes any pwd a git file. Its snapshots are now taken.
- Git add adds your working tree to a staging area == index
- To commit and stage at the same time, use: Git comit -a -m “message”
- While working on someone else's project, we need to set remote to make changes: git remote set-url origin https://github.com/minervaDutta/jest-tests.git
Setting up git repo (source-GitHub: Original github repo -> local -> your GitHub repo:
- git clone {source repository name} -> opens a repository locally
- git remote set-url origin {your new empty repository name} -> You set up an upstream link to upload
- git branch -m "main"
- Note: forking allows you to create a new repository which can then be cloned, you can also create a brand new one (here I have used the latter)
Setting up git repo from local to GitHub:
- git init -> activates git locally
- git branch -m "main"-> renames from master, remember in GitHub, string keywords are in “”
- git remote add {remote-name like origin} {GitHub-repo-name}
- git push --set-upstream origin main
Collaborating on a github repo
- git clone
- git init -> Initialize local repo
- git pull origin master --rebase
- git add .
- git commit -m "message
- git push origin master
- git pull and git push done this way avoid conflicts when we use overlapping names on remote and local