Steps for working on a new Project from scratch:
Precondition: You have already created a Github repository to commit codes to.
- git init (Initialize git repository)
- git status (check for untracked and tracked files)
- git add . (for all files) or git add {filename}. (for a specific file)
- git commit -m “message” (save changes to the local repository)
- git remote add origin {remote url} (connecting to Github repository)
- git push origin master or git push origin {branchname} (pushing code from local to remote master branch or other named branch)
Note : Please remember not to work on the master branch directly, always create different branches for different purposes. To work on branch use the following command always before adding codes to the staging area:
git checkout -b {branchname}
Steps to start working with other's repository and contributing:
Precondition: Fork the repository in Github which you want to contribute to.
git clone {remoteurl} (Clones your fork repository in local. For first time user)
or
git pull {original_repo_url} master (To always pull the latest code from main repository, from second time don't clone but pull)git checkout -b {branchname} (Change the branch from master to other)
git add . or git add {filename}
git commit -m “message” (save changes to the local repository)
git remote add origin {remote url} (connecting to Github repository)
git push origin {branchname} (pushing code from local to remote branch)
NOTE: Post push request go to Github and create a pull request so that your changes can be added to the main program and be viewed by others too.
Top comments (1)
Nice one...
Short & sweet 👍