This is section helps you to make new features, corrections or other changes. Acceptance of these changes is made in another step.
To really understand git, always (always) use tool to visualize the git repository in a graph way. Then you will understand what is happening. In VSCODE you can use "Git Graph ". Also there is gitg for Linux and many others.
git clone https://git_repository_url
Clone a repository. Then you can start working in a project.
git checkout develop
From what branch yours changes must be based? Ask for your team, usually (if the team use de gitflow style) it is called develop.
If it is not your first time in the develop branch, you will have to do git pull
.
git pull
This command will download and update the current branch according to the origin (server). It will download and merge the remote content (code). Merge means that git will compare the differences and merge the two source code. If it fails, it will ask you to solve the merge (look at the source code and choose/implement the right change).
Yes, the local branches are not the same in the origin (server). You copy then to your local machine and update them from your local machine.
So, use git fetch --all
to copy all branches updates to your local machine.
When you enter on a branch
git checkout -b new_branch
If you are going to make changes, make it on a new branch. Never make any change on the important branches like master or develop
Also, choose a decent name for your branch. If you are doing a new feature, could be feat_nameOfTheFeature_YourIdOrIdFromOtherSystem. Each team will have its guidelines for these names, the important is: be consistent, all members must follow a pattern.
git commit -m "Description of my first changes"
Cool, you have made some code changes. Use this command to save the changes on git. Remember, for now you are saving only in your local machine. You can do any number of commits, to save different stages.
git push
git push --set-upstream origin new_branch
Changes made! It is time to send to origin (server). If it is a new branch, use with the
--set-upstream
param.
If not, use just push.
You can use push, before you have finished, to have a backup on the server. Remember, commits will only save in your local machine. Of course, check with your team if it is ok to have a backup.