Jump to content
Encoded

Git Tutorial

Recommended Posts

hIUWbqc.png

What is Git?
"Git is a version control system (VCS) for software development. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows." - Wikipedia
In simpler terms, git allows you to revert changes in your project if needed and allows you to easily collaborate with others. 
How do I get Git?
You can follow the download instructions for your OS here: http://git-scm.com/downloads
 
After installing git, you will want to set your name and email.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Creating a Repository
We are assuming you have already set up a project via an IDE.
cd to the main directory of your project and git init to create the repository.

cd IdeaProjects/TRiBot/src
git init

Adding and Committing files to the Repository
Think of commits as different versions of your project. You can switch between commits as needed. You can add entire directories as well as individual files.

git add scripts/ExampleScript.java
git commit -m 'Descriptive commit message'

Status
We can use the git status command to display the state of the working directory and the staging area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git. Status output does not show you any information regarding the committed project history. For history you use git log.

git status

Viewing Commit History
We use the git log command to view commit history. There are many parameters that can be added to the log command to further refine the returned commit history.

git log

Reverting to a Previous Commit
To revert to a previous commit we use the git checkout command.

git checkout <commit>

If we only want to revert a specific file, we can do so.

git checkout <commit> <file>

You now should know enough about git to be able to easily revert any undesirable changes to your scripts and increase development speed and efficiency.
 


Uploading and Pushing to a Remote Repository

We will assume you already have a git repository setup. Now you just need to add the url to remote repository and push to it.

cd /path/to/my/repo
git remote add origin https://[email protected]/Encoded/example.git
git push -u origin --all # pushes up the repo and its refs for the first time
git push origin --tags # pushes up any tags

Now when you make commits, you can push them to the remote repository.

git push origin master

Origin is the remote name and master is the branch name.


Using branches, collaborating with others, and IDE integration coming at a later time.

Edited by Encoded
  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Our picks

    • This release will:

      Fix key event handling issue


      Fix other event handling issue


      Fix RSServer hook


      Update world hopper to have it use OCR, thanks to Todd


      Use proper disposal of old Graphics objects


      Reformat code


      Rearrange code


      Organize code imports


      Apply around 8000 automated code refactorings


      Make preparations for Java 9


      Fix 11 various bugs


      Add more reliable debugging support


      Fix mouseEntered/Exited event dispatching bug


      Fix minimap walking bug where it opens the map


      Fix broken hooks for today's game update
        • Thanks
        • Like
      • 55 replies
    • This update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
        • Like
      • 27 replies
    • This release will:

      Fix some ClosedChannelException bug


      Fix bug in RSObject#getAllTiles


      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug


      Fix game object location bug


      Fix small layout bug making the client shift up and down


      Fix client crashing bug where loading the client with a small display area will cause the client to crash


      Fix annoying Linux bug relating to painting events and peers


      Fix settings saving bug where settings are saved to disk more often than they should


      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people


      Drop Java 1.7 bytecode version for 1.8


      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).


      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×