How to Git - MDHSRobotics/TeamWiki GitHub Wiki
-
First go to the project you want to clone in GitHub and make sure its the master branch. From there copy the link of the project on the side.
-
From there open your command prompt then navigate to the directory where your projects are kept. Usually a folder called repository.
-
From there type the command
git clone [url]
. Fill in GitHub username and password if required. -
Done. The project should be in your directory now. To import, open eclipse, click file at the top, click import, click "existing projects into workspace", then select your project, then import.
After navigating to the local directory of the repository, the typical sequence of commands:
- get latest from the remote repository
git fetch
- check out the local repository
git checkout
- do some work, e.g. add, edit or remove files as needed. "Stash" to hold onto any changes you might want to use in the future.
- "when you don't want to commit changes but want to fetch and pull" code
git reset --hard origin/master
(note: be aware what branch you are committing to. for more info click here)
- add changes to local repository
git add .
- commit changes
git -c user.name="<USERNAME>" -c user.email="<EMAIL>" commit -m "<MESSAGE>"
replacing
+ <USERNAME> with your git user name
+ <EMAIL> with your email
+ <MESSAGE> with a message to associate with the changes you have made
+ example:
git -c user.name="CAMPSMITH" -c user.email="[email protected]" commit -m "adding images"
- pushing changed to the remote repository
git push