Welcome to the Git/Github tutorial repository! Here we will aim to demo a series of useful workflows to get started:
- Cloning a repo
- Creating a new branch
- Pushing the branch, creating a pull request
- Merging changes from another branch, dealing with merge conflicts
If there is an existing remote repository you'd like to start development on, usually the first thing to do would be to clone that repository to your local machine. To obtain a local copy of any repo, go to a directory you'd like to place the repo in, and run:
git clone <REPOSITORY_URL>
For this repo, the command to run locally will be:
git clone https://github.com/pqz317/cnc_github_tutorial.git
The URL can always be found under the "Clone" Section of the Github page of the repo:
Once cloned, you should have a directory cnc_github_tutorial in your local filesystem. Run git status to verify that the directory is a git repository, and that you are on the main branch. An example output:
Patricks-MacBook-Pro:cnc_github_tutorial patrick$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
You have now successfully cloned a repo!
One general convention is to keep the main branch tracking origin/main, and perform any development on a different branch
To do this, run:
git checkout -b <SOME_BRANCH_NAME>
This will checkout create a new branch, and switch over to that branch. Any changes you make to files now will occur on this new branch, and not affect main. Using your favorite text editor, feel free to make any changes to the test_file.txt file.
Once saved, we can check the status of our branch using
git status
and add + commit our changes using:
git commit -am "<SOME COMMIT MESSAGE>"
Currently your new branch only exists locally and not in the remote repository.