Upload local project using Git (to GitHub)
- On GitHub, create repo (eg. port2020) without any files.
- From Shell:
git init
git add .
git commit -m 'message'
git remote add origin https://github.com/CRTejaswi/<REPO>.git
git remote --verbose
git push origin master
Common Tasks
Common Issues
- Exclude certain files/folders:
Include filenames in a.gitignore
file (in root of repository). - Remove files you have added by mistake:
This does not affect the file on your PC.
git reset README.html
- Lookup previous changes (commits):
git log git log --pretty=oneline
Working In A Group
-
Create your own copy of a project
This is called FORK on Github. -
Remote v Branch
remote
refers to the url of the remote copy of the project.
eg.origin
is an alias for the main url of your project.
branch
refers to parallel "branches" of the same project.
These are used to work on specific tasks apart from the main workflow.
To check all remotes/branches for current project, use:git remote git branch
This is how a complete PUSH command looks like. If you leave out remote/branch (
git push
), the current values are used:git push <remote> <branch> git push origin master git push origin feature
-
Feature Branches
- Switch between feature branches:
git branch <- List all available feature branches. git checkout -b <new_branch> <- Create a new branch, then switch to it. git checkout <existing_branch> <- Switch to an existing branch. git checkout master <- Switch to main workflow (master branch)
- Add completed features to main workflow:
git checkout master git merge --squash <BRANCH>
- Delete a branch locally/remotely:
git branch -D <BRANCH> git push origin --delete <BRANCH>
- Switch between feature branches:
-
Make changes to main project
Submit a PULL Request on Github.
Pull requests cannot be deleted from project history. So, ensure that you give concise info at each stage so there's less clutter in the discussion.