Authors: - Kangfeng Ye
Title: Git Usage ...
Keywords: Git
Git Introduction
Git is a distributed version control system.Understanding the key Terminologies
Commands
git add
- add changes in the working tree to the staging area or called staging
- allows you to incrementally modify files, stage them, modify and stage them again until you are satisfied with your changes
An example
- show current working tree status
$ git status -s
- add a new file, and edit it to add contents
$ echo "git add test" > readme.txt
- query status and it is untracked
$ git status -s
?? readme
- staging it and query status again.
A
- staged
$ git add readme
$ git status -s
A readme
- modify it and query status again.
AM
- the file has been changed but the change is not staged
$ echo "staging, then modify again" >> readme
$git status -s
AM readme
- staging it again. It comes back to staged again.
$ git add readme; git status -s
A readme
Another example to test
- query current status
$ git status -s
A readme
- show file and it's staged content
$ cat readme
git add test
staging, then modify again
- modify it, but no staging
$ echo "no staging" >> readme
$git status -s
AM readme
- commit it
$ git commit -m
Troubleshooting
A scenario
- create a local git repository
$cd /mnt/share/rfid_tracker
$ git init
$ touch readme.txt
- clone from repository
$cd ~/src/
$ git clone /mnt/share/rfid_tracker rfid_tracker
- a clone is in rfid_tracker folder
- modify the readme.txt file and commit in clone
$ git commit -m "change" readme.txt
- push to original repository
$ git push
- an error occurs
remote: error: refusing to update checked out branch: refs/heads/master
error: failed to push some refs to /mnt/share/rfid_tracker
- solution (make original reposity as bare)
$ cd /mnt/share/rfid_tracker
$ mv .git .. && rm -fr *
$ mv ../.git .
$ mv .git/* .
$ rmdir .git
$ $ git config --bool core.bare true
No comments :
Post a Comment