-
Notifications
You must be signed in to change notification settings - Fork 0
git
Git is a source code management system that features distributed storage and emphasizes speed and data integrity.
Git allows multiple users to work on a project simultaneously and keep their files up-to-date with each other. The "distributed" aspect of Git means that instead of having one central repository, like with SVN, that users push to and pull from, everyone has a local copy of the repo, making their changes as needed, and can update the central copy so others can be in sync. One advantage of this system is that it makes the repository robust against failure of the central server's data storage mechanism (or failure of any local copy for that matter). Changes can also be made and committed offline and later simply pushed to the server. Git also keeps "snapshots" of the repository, allowing for a rollback to a stable version if something were to irreparably corrupt the latest branch of the repo.
Files can be in several states (revealed by "git status"):
-Untracked: New files that have not been added to the list of files git should track. Use "git add".
-Staged: File has been added to the tracking list, but has not been written to the repository. Use "git commit".
-Modified: File is tracked and has been changed since last update, but changes have not been written to the repo. Use "git commit".
-Committed: Changes have been updated in the local database. Use "git push" to sync these changes with the central repo. ("git status" will report that you are ahead of branch "master" if you need to push)
-Create a file (ex: ECEN489-Spring2016/Students/tbranyon/HW1.c)
-Add file to repository
$ git add HW1.c
-Commit changes
$ git commit -m "Adding first homework source code"
-Push changes to central server
$ git pull #update local copy first
$ git push
ex: Teammate adds a source code file and asks you to debug and edit it.
-Retrieve new source code
$ git pull
(Git pulls in new file(s)...)
-Make your changes, file is now in modified state
-Commit changes
$ git commit -m "Modifying project1.java to include error-correction routine"
-Push new changes to server
$ git pull #update first!
$ git push
-Done!
If there is a conflict while trying to pull, Git will exit with an error, notifying you to manually resolve the conflict.
git clone <URL>
Creates a new local copy of a remote repository located at <URL>
git status
Shows state information for your local repository
git add <FILENAME>
Adds a new file to the list of files git is tracking
git rm <FILENAME>
Removes a file from the repository. Simply deleting the file from your hard drive will not accomplish this.
git commit
Writes changes into the local repo database with an optional message
git reset
Unstages staged files
git push
Sends your updated copy of the repo to the central server (Local copy must be up to date first)
git pull
Updates local repo with all changed files from central server. Will not affect locally changed but uncommitted/pushsed files that are not changed on the server.
(Credit: XKCD)
