-
Notifications
You must be signed in to change notification settings - Fork 0
Git Cheatsheet
Here are some common actions performed with git and how to do them.
- I want to start working on a feature
- I want to publish my changes
- I want to incorporate changes in master in my branch
- I want to merge my code into master
- I want to get a fresh copy of
2016
on my computer
A good first step is to make sure you have the latest version of master.
git checkout master
git pull
Next you should make a feature branch. There are two ways to create the branch and check it out:
git branch <BRANCH_NAME>
git checkout <BRANCH_NAME>
OR
git checkout -b <BRANCH_NAME>
Where <BRANCH_NAME>
is the name of your branch. You can now go ahead and make whatever changes you want to the code.
The first thing to do is "stage" or add the files you want to commit. Do this with:
git add <FILENAMES>
Where <FILENAMES>
is a list of files to be added, each separated by a space. If all of the files you want to add are in the same folder, you can instead type <FOLDER>/.
. For example, if all files are in the src
folder, type:
git add src/.
If you added a file by mistake and want to un-add it, use this:
git reset <FILENAMES>
Or if you want to un-add all files just type git reset
.
The next step is to commit the changes locally. To do this, commit the files you have added:
git commit -m "<MESSAGE>"
Replace <MESSAGE>
with some meaningful description of what you changed.
Next you have to publish your local changes to the git server so everyone will receive them. Simply type:
git push
If it is your first time pushing with your feature branch, git will tell you that the branch doesn't exist and will give you a command to type (git push --set-upstream origin <BRANCH_NAME>
). Just copy-paste it in.
As master is being updated, it is good to keep your branch up to date with it. This is especially true when you want to merge your code into master. To do this, check out master and get the latest changes:
git checkout master
git pull
Then go back to your branch and merge master into your branch:
git checkout <Your_BRANCH>
git merge master
Doing the merge may open a command line text editor. Type :q
to quit the editor and complete the merge.
If the merge has conflicts, you will need to change the files manually to resolve the merge, then commit
the changes.
Once you have merged successfully, do a git push
to publish these updates.
You don't need the command line for this! Go to the "Pull Requests" section on GitHub, click "Create New Pull Request", then select the branch you wish to merge into master. Before clicking the merge button, you need to:
- Make sure your code passes the continuous integration (CI) tests
- Have your code reviewed and approved by another developer
Just cd
to the directory where you want the code to live and type
git clone <URL>
Where <URL>
is the URL on the project's main page under the "Clone or Download" button
This wiki and the project's README file contain a lot of information, take your time and read both. Read the CONTRIBUTING.md
file in the project before opening a pull request or an issue.
© Eastern Edge Robotics - www.easternedgerobotics.com
Introductions
- Home
- 1000ft overview
- Design rationale
- Configuration
Getting things done
- Quick start
- Getting Started/Workspace Setup
- Git-Cheatsheet
- Vagrant environment
- Connecting to the ROV network
- Walkthrough: Adding a feature
- Testing changes to the application
- Deploying the application
- Running the application topside
- Running the Picamera video feed
Development
Hardware and misc.