Okay, you’ve been tasked with a project and it’s using GIT for version control but you have never used GIT. Don’t worry I will lay out a typical GIT workflow that will get you through.
The first thing you will need to to do is clone the GIT repository, this is simply done with the git clone command:
git clone http://link_to_the_repo.git
This will create a copy of the repo to your local machine. Now you have a local copy you will need to ‘branch’ from the current branch to make your changes. This simply means all your changes will be on your own branch and not on the master branch.
git branch my-branch-name
You can call your branch whatever you wish but most places will have a set format such as your initials + a issue number. Now you have created your branch you need to switch to it, you can do this by ‘checkout'(ing) out the created branch:
git checkout my-branch-name
All your code changes will now be made on your branch and you branch only. If you’re ever un-sure what branch your working on or the status of your project then simply call git status which will give you all the details you need:
Now that you have confirmed you’re on the correct branch make your changes to the code. Once you have finished your changes run git status again and it will list all the files you’ve changed or created. To commit these changes you first need to ‘add’ them, you can add all your changes by using a period:
git add .
This will now stage all your changes but this is still only visible locally so lets change that. We can use a command called ‘commit’ which records our changes to the branch:
You will be promoted to enter a message for the commit, keep this brief and to the point explaining what changes you have made. Now the final piece will be to ‘push’ your changes:
git push -u origin my-branch-name
That's all that's needed, your code is now added to the repo on your own branch. What happens now? A senior dev will pick this code up, probably for a code review and if the code passes their review they will do a 'git merge' into the main branches, most likely the development branch for testing and then eventually they will merge the development branch into the master branch when the software is ready to be released.
This was a rapid tour, there are many more steps and actually a few different ways of achieving the above like checking out directly from a branch with the -b flag will also create you a branch all in one command but this workflow should get you up and running quickly in most cases.