Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Monday, December 30, 2013

Repository Transfer


Finally I have removed all of my github repositories. I have been getting request from a lot of people for removing the repositories or making them private. As github charges too much for maintaining private repositories, I have decided to switch to bitbucket, another wonderful free git server. All of my repositories are set as private. Sorry for the inconvenience. There are already plenty of sites where one can find solutions for online judge problems. My repositories were never intended to be known as a place where you get all the beautiful solutions and then just copy-paste them from your account. That is just meaning-less, stupid and of no good use of-course. Still if you want to see any of my noob-ish solutions, please send me an email.

Thanks for understanding and happy problem solving. I think I am now retired from all these beautiful little things. I will miss these programming contests forever...

Sunday, June 23, 2013

Git Cheat Sheet


Most commonly used git commands

 git init     # initializes an empty git in the current directory  git config -l git config --global user.name "<your name>" git config --global user.email "<your email>" git config --global color.status auto git config --global color.diff auto git config --global color.branch auto  git clone <git host>:/repo/<projectName>     # copy a git repository so you can add to it  git add <file1 file2>     # adds files to the staging area git add .     # recursively add all files under current directory git add *     # add all files in current directory only  git checkout -- <file>     # reverts back the modified file to the one in the repository  git status     # view the status of your files in the working directory and staging area git status -s     # short form. Left column for staging area. Right column for working dir  git diff     # show diff of unstaged changes git diff --cached     # show diff of staged changes git diff HEAD     # show diff of all staged or unstaged changes  git commit     # records a snapshot of the staging area git commit -a     # stage modified files before commit. Does not add new files, but removes deleted files from staging area git commit -m 'commit message goes here' git commit --amend     # Update the last commit message git commit --amend --reset-author     # Use this if you have changed your user name or email with git config and want to fix this identity for previous commit  git reset --hard HEAD     # This will throw away any changes you may have added to the git index and as well as any outstanding changes you have in your working tree. git reset HEAD     # unstage all changes that were staged. Reset staging area to HEAD git reset HEAD -- <file1 file2>     # unstage files. Reset the file to its snapshot in HEAD  git revert HEAD     # This will create a new commit which undoes the change in HEAD (i.e. the last commit). You will need to enter the message for the new commit. git revert HEAD^     # Git will attempt to undo the old change while leaving intact any changes made since then.  git rm <file1 file2>     # remove files from staging area and working dir git rm --cached <files>     # remove files from staging area only git rm -r subdir/     # path = * to recursively remove subdirectories from staging area and working dir  git pull  git branch -a git branch <branchName>     # create new local branch at your last commit. So all commits of current branch will be copied over to the new branch. git push origin <branchName>     # push a new local branch to the server. If you do not explicitly push your new local branches, they stay in your repo and are invisible to others git pull origin <branchName>     # pull a remote branch git branch -d <branchName>     # delete branch. This command ensures that the changes in the branch (to be deleted) are already in the current branch. git branch -D <branchName>     # delete branch. This command will NOT check if the changes in the branch (to be deleted) are already in the current branch. git push origin :<branchName>     # will delete the branch on the origin remote git branch --track <master> <origin/master>     #Add release branch?? git checkout <branchName>     # Switch the branch you are currently on git remote git remote show <origin>     # Lists the URL for the remote repository as well as the tracking branch information  git log <release> git log --name-status git log -p git log --pretty=full git log --no-merges     # Ignore merges git tag -l     # list tag names git tag -a v1.4 -m 'version 1.4'     # Create tag with annotation git tag v1.4     # Create tag without annotation git push --tags     # Push tags to remote git show <tagname>     # Show tag and tagger details  #To rename a tag: git tag NEW OLD     # First create NEW as an alias of OLD git tag -d OLD     # Delete OLD git push origin :OLD     # Delete OLD in remote branch  git stash git stash apply git stash list git log stash@{2} git show stash@{32} git reflog git reflog expire --expire=30.days refs/stash 

Looking for anything else? Please refer to Git Documentation page.


Monday, May 7, 2012

GIT What I Need


Mainly I use GITHUB for my personal repository so that I can access some files not when I am home, and every time I try to add something to github from my local repository, I almost always forget the commands. That's why I am writing the three line commands I will always need, just for my convenience :)

git status -s
git add <filename>

git config --global user.name "<my_name>"
git config --global user.email <my_email>

git commit -m "<my_commit_msg>"

git push origin master

That will do for now. A total reference can be found here.