Most new developers find Git/Github quite complicated and difficult to use. Good news is you can use Github if you understand or follow about 6 commands. Today I am going to share the git commands/procedures which every coder should know.
Step 1: Creating an account on Github. If you already have one, skip to step 2. Otherwise follow this link to create your account.
Step 2: Creating your new Github repository. Do this by logging in to Github, and create project.
Step 3: At the point you have two options: clone it (create a duplicate of the repository on your local machine), or create a local repository on your local machine and link it to the remote (Github) repository.
git clone https://github.com/lornatumuhairwe/trial.git
in your directory, creates a clone of the Github remote repository on the computer it is run.
- For any changes you make, run the following commands
git add .
Significance: Adds all files for tracking. Note the . at the end of the command.
git commit -m "your message"
Saves the changes made as a version of your program
git push -u origin master
Pushes the code to Github so that your local and remote repositories are similar
- Initialise a git repository locally by running the command below:
- Then the other commands as above
git add .
git commit -m "my message"
- Link the repository to the remote repository by running:
git remote add origin https://github.com/lornatumuhairwe/trial.git
- Push code to the remote repositpory git push -u origin master
Get familiar with that. You can see more info on collaboration and branches on the Github documentation and the Git cheatsheet.