Nice and clean!
http://learn.github.com/p/intro.html
http://learn.github.com/p/setup.html
http://learn.github.com/p/normal.html
http://learn.github.com/p/branching.html
http://learn.github.com/p/remotes.html
http://learn.github.com/p/log.html
http://learn.github.com/p/rebasing.html
http://learn.github.com/p/undoing.html
http://learn.github.com/p/git-svn.html
Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts
Wednesday, September 26, 2012
Sunday, September 16, 2012
Friday, September 7, 2012
Git re-initialize fix after corruption
Today, a project directory was somehow corrupted and cannot add new file nor commit modified files to the local repository.
With error like these:
$ git add .
error: insufficient permission for adding an object to repository database .git/objects
error: clickthecity.rb: failed to insert into database
error: unable to index file clickthecity.rb
fatal: updating files failed
It's found that some directories under .git/objects were owned by root. Maybe some commits were done under the root access.
After a few tries in vein, I do just re-initialize the local git repository.
$ sudo rm -rf .git
$ git init
$ git add .
$ git remote add origin [your_server]:[dir]
$ git commit -a -m "..."
$ git pull origin master
And do some code merging.
$ git push origin master
Done.
With error like these:
$ git add .
error: insufficient permission for adding an object to repository database .git/objects
error: clickthecity.rb: failed to insert into database
error: unable to index file clickthecity.rb
fatal: updating files failed
It's found that some directories under .git/objects were owned by root. Maybe some commits were done under the root access.
After a few tries in vein, I do just re-initialize the local git repository.
$ sudo rm -rf .git
$ git init
$ git add .
$ git remote add origin [your_server]:[dir]
$ git commit -a -m "..."
$ git pull origin master
And do some code merging.
$ git push origin master
Done.
Thursday, August 9, 2012
Setup Git server on Linux
- Setup ssh login
- ssh [your_name]@[server_name] mkdir .ssh
- scp ~/.ssh/id_rsa.pub [your_name]@[server_name]:.ssh/authorized_keys
- Install Git:
- ssh [server_name]
- sudo apt-get update
- sudo apt-get install git-core
- If a shared repository is need, create a git user:
- sudo adduser git
- ... cont on setup ssh login.
- Add repository
- Login as your_name or git
- mkdir myrepo.git
- cd myrepo.git
- git --bare init
- Setup development machine
- git remote add origin [server_name]:myrepo.git
- git push origin master
- Done
Monday, July 9, 2012
Git daily usage cheat sheet
Task | Command |
---|---|
Initialize a new git repository |
git init
|
View local branches | git branch |
Create new local branch | git branch [new_branch_name] |
Delete local branch | git branch -d [branch_name] |
Switch to a branch | git checkout [branch_name] |
Add files to git | git add . |
Undo all current changes. | git checkout . |
Commit changes | git commit -a -m "Log message" |
Show git logs | git log |
Push local to remote | git push origin [branch_name] |
Pull from remote | git pull origin [branch_name] |
Merge branch | git merge [from_branch] |
Show diff | git diff |
Show all branches | git branch -a |
Fix a tagged release |
git checkout -b [tag_name]_fixes [tag_name]
OR (for getting a remote branch)
git checkout -b [new_local_branch] origin/[remote_branch]
e.g. git checkout -b myfeature origin/myfeature
|
Create a new tag | git tag [tag_name] |
Push tags to remote | git push --tags |
Overwrite existing tag | git tag -f [tag_name] |
Delete tag |
git tag -d 12345
git push origin :refs/tags/12345
|
Merge individual commits | git cherry-pick [commit_hash] |
Stashing |
git stash
git stash apply
git stash list
|
Create an empty repository | git --bare init |
Adding a remote repository |
git remote add origin [server_name]:[directory_name]
|
Checkout a single file on another branch:
$ git checkout branch_name file_full_path
More on: http://gitref.org/index.html
$ git checkout branch_name file_full_path
More on: http://gitref.org/index.html
Labels:
Cheatsheet,
Favourite,
Git
Tuesday, February 28, 2012
Github - Source control
Free public repositories, collaborator management, issue tracking, wikis, downloads, code review, graphs and much more…
https://github.com/
Subscribe to:
Posts (Atom)