uploaded from otxe6530::git-memo
git reset --soft HEAD^ #and move from that commit to staging
git reset --hard HEAD^ #and wipe changes, files aren't put in staging (reverted)
git reset --hard HEAD^^ #revert to 2 commits back
Here's a comforting quote from Scott Chacon:
One of the topics that I didn't cover in depth in the Pro Git book is the reset command. Most of the reason for this, honestly, is that I never strongly understood the command beyond the handful of specific use cases that I needed it for. I knew what the command did, but not really how it was designed to work.
git reset HEAD <file>
git rm --cached <file> # _not deleted from local filesys, only from git_
git checkout -- <file>
git add <file>
git commit --amend -m "text" #as if file was commited in last + replace commit txt
git add "*.txt"
origin
is a shorthand (like variable name) to the URL, "origin" is a convention
git remote add origin https://github.com/....
show remote repositories:
git remote -v
git push -u origin master # "-u origin" is for next time, we'll just type 'git push'
Explained in https://help.github.com/articles/set-up-git
- The credential helper only works when you clone an HTTPS repository
- Fast-Forward means
merge branch to master, nothing changed on master since branch
- fetch = sync local repo with remote
fetch updates "origin/master" - a branch! mirroring the remote master - merge = perform
git merge origin/master AUTO and IMMED after the 'pull'
git checkout -b shopping_cart
git push origin shopping_cart # _link local to remote and start tracking_
git remote -v
git remote show origin
- VERY important: shows where repo came from etc.
in the example below, we see this local repo is connected with bitbucket, state of local and remote branches...
=============================================
[18:03:08]ori@otxe6530[OstkInstal]
$ git remote show origin
Warning: Permanently added the RSA host key for IP address '131.103.20.167' to the list of known hosts.
Enter passphrase for key '/home/ori/.ssh/vubu10LTS.id_rsa.priv.pass_protected':
* remote origin
Fetch URL: git@bitbucket.org:otzoran/ostkinstal.git
Push URL: git@bitbucket.org:otzoran/ostkinstal.git
HEAD branch: master
Remote branches:
master tracked
refs/remotes/origin/yokamina-s13 stale (use 'git remote prune' to remove)
yokamina tracked
Local branches configured for 'git pull':
master merges with remote master
yokamina merges with remote yokamina
Local refs configured for 'git push':
master pushes to master (up to date)
yokamina pushes to yokamina (up to date)
==============================================
- ? what does "tracked" means? other values seen:
grizzly new (next fetch will store in remotes/origin)
refs/remotes/origin/yokamina-s13 stale (use 'git remote prune' to remove)
yokamina tracked
- del remote
git push origin :shopping_cart
- del local
git branch -d shopping_cart
Now "stale" means the remote was deleted, local still exists
if i try to
git push
to this non-existent remote, git says
Everything up-to-date
Cleanup remote stale branches:
git remote prune origin
Pruning origin
URL: https:....
* [pruned] origin/shopping_cart
example using Heroku deploys only master branch
git push heroku-staging staging:master
a tag is a reference to a commit - used mainly for Release Versioning
checkout code at commit:
git checkout v0.1
to push new tags:
git push --tags
- if not, tags remain local
reason [?] "merge commits are polluting the history"
- The awesome: shows the FULL history of repo, where is HEAD, tags, remotes and oneline comments in a graph
git log --all --graph --decorate --pretty=oneline --abbrev-commit
See full reply on (Stackoverflow)[http://stackoverflow.com/questions/7758113/how-to-git-log-the-entire-repository-and-not-just-the-branch-you-are-on] including how to add a git alias
- log format options
- git blame
- exclude: line in
.git/info/exclude
can replace a line in.gitignore
, in which case it's not visible - my
ogitlog
alias ogitlog='git log --pretty=format:'\''%C(yellow)%h %Creset%ad %C(magenta)%an%Cgreen%d %Creset%s'\'' --date=iso'
taken from: http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/
[remote]
mkdir ori_test.git
git init --bare
[local]
remote add origin ssh://lux@54.221.17.172/home/lux/ori_test.git
git push -u origin master
- note that the remote dir is in .git format, it doesnt extract the files after the push
- need git clone to another dir [on remote] to use the files
gitsis
gitorious