This page gathers some instructions around the git functionalities we'll use throughout the workshop, so feel free to consult at any time!
For full documentation on this command check the git docs.
- To clone a repository follow the instructions on this GitHub article
This Git Branching doc is a very comprehensive guide to Basic branching and merging, and it's worth the read if you're new to git and it's architecture. Also, worth to know about GitFlow, which is one of the most used branching models (either pure GitFlow or some variation of it).
To create a new branch:
git checkout -b <your-branch-name>
If you don't like to write your commit messages in a console text editor, you have the option to change which editor git opens up by default. To do so, run:
git config --global core.editor "<your-preferred-editor>"
For windows, for example, you can run the above command with "notepad.exe"
as your preferred editor.
If you have changed this before, you might need to provide --replace-all
to overwrite the configuration.
For more info on commits, see the docs and this useful article on Saving changes on git.
To commit new changes:
- Prepare the new files for the commit by adding them to the staging area:
git add <file-path>
- If you have too many files to add (and are confident all files will need to be committed), you can opt for
git add --all
, which will add all the files into the staging area.
- Then, commit your code via
git commit
- You'll be redirected to a text editor to add your commit message.
- If you're running it via Terminal within Visual Studio Code, you'll most likely have Vim as your editor.
Typei
to start editing, and when you're ready, typeEsc
, then:wq
to save and exit.
Alternatively, you can change git default text editor to something you're more comfortable with. - Add a proper description to your commit message. Keep in mind that this message will be kept in the repository history, therefore it needs to be clear and descriptive as to what it's addressing/implementing. Ex: Workshop1 - Adding generated react app.
For more info on pushing your changes, see this GitHub article and the docs To push new changes:
- With all the changes committed, the next step is to Push the code to GitHub:
git push origin <your-branch-name>
Important: The first time you Push your branch to a remote, you'll need to add the-u
flag, which will tell git to create the branch remotely before pushing the code.
- Writing good commit messages
- GitHub Git cheatsheet
- Learn git branching: Interactive resource for learning more about git and its concepts.