Last active
August 29, 2015 13:57
-
-
Save basharam/9512082 to your computer and use it in GitHub Desktop.
git V1.7.9.5 First Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git V1.7.9.5 First Time | |
:::::::::::::::Non Bare repo::::::::::::::::::::::::::::::: | |
+++++++Use case 1+++++ | |
$ git clone ~/ext/test_nb_repo/ testnb | |
$ cd tesnb | |
$ cat README | |
$ vi README | |
$ git add * | |
$ git commit -am "rem line 4 in readme" | |
$ git status | |
# On branch master | |
# Your branch is ahead of 'origin/master' by 1 commit. | |
# | |
nothing to commit (working directory clean) | |
$ | |
$ git remote -v | |
origin /home/xx/ext/test_nb_repo/ (fetch) | |
origin /home/xx/ext/test_nb_repo/ (push) | |
$ git push /home/xx/ext/test_nb_repo/ master | |
Unpacking objects: 100% (3/3), done. | |
remote: error: refusing to update checked out branch: refs/heads/master | |
remote: error: By default, updating the current branch in a non-bare repository | |
remote: error: is denied, because it will make the index and work tree inconsistent | |
remote: error: with what you pushed, and will require 'git reset --hard' to match | |
remote: error: the work tree to HEAD. | |
remote: error: | |
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to | |
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into | |
remote: error: its current branch; however, this is not recommended unless you | |
remote: error: arranged to update its work tree to match what you pushed in some | |
remote: error: other way. | |
remote: error: | |
remote: error: To squelch this message and still keep the default behaviour, set | |
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. | |
To /home/xx/ext/test_nb_repo/ | |
! [remote rejected] master -> master (branch is currently checked out) | |
error: failed to push some refs to '/home/xx/ext/test_nb_repo/ | |
---- | |
Fix: on Server | |
~/ext/test_nb_repo $ git pull ~/junk/tmp/nbtest/(Name of the cloned repo) master | |
---- | |
Back on clone repo issue: | |
$ git status | |
# On branch master | |
# Your branch is ahead of 'origin/master' by 1 commit. | |
# | |
nothing to commit (working directory clean) | |
$ git fetch | |
From /home/xx/ext/test_nb_repo | |
f0fa981..f3a752c master -> origin/master | |
$ git status | |
# On branch master | |
nothing to commit (working directory clean) | |
$ | |
+++++++Use case 2+++++ | |
$ git clone ~/ext/test_nb_repo/ testnb | |
$ cd tesnb | |
$ git checkout -b temp | |
Switched to a new branch 'temp' | |
$ git branch -a // lists local and remote branch | |
$ git branch -r // lists only remote branch | |
(work) | |
$ git add * | |
$ git commit -am "comments" | |
$ git status | |
# On branch temp | |
nothing to commit (working directory clean) | |
ON sever pull changes in temp branch | |
~/ext/test_nb_repo$ git pull ~/junk/tmp/nbrep/ temp | |
Back on client | |
$ git pull ~/ext/test_nb_repo/ master | |
--------------------------- | |
:::::::::::::Bare repos ::::::::::::::: | |
Bare repositories (by definition) don't have a working tree attached to them, | |
so you can't easily add files to them as you would in a normal non-bare repository | |
(e.g. with git add <file> and a subsequent git commit.) | |
You almost always update a bare repository by pushing to it(using git push) | |
from another repository. | |
Also, it's conventional to give bare repositories the extension .git. | |
So, your sequence of commands should be: | |
mkdir test_repo.git | |
cd test_repo.git | |
git --bare init | |
git clone ~/ext/repofolder/ test | |
cd test/ | |
git checkout -b makestatus | |
git status | |
(work) | |
git add * | |
git commit -am "comments" | |
-- Now Merge makestatus branch with master-- | |
git checkout master | |
git pull origin master | |
git merge makestatus | |
git push origin master | |
--verify wit gitk that master,makestatus,remotes/origin/master points same commit | |
::::::::git quick command::::::::::::::: | |
git --bare init // create bare | |
git init // non bare | |
git add . // add all new and modified files to the stage. | |
git add -u // automatically stage tracked files -- including deleting the previously tracked files. | |
git commit -am "comments" | |
git remote -v | |
git branch -a //lists both remote and local branches | |
git branch -r //lists only remote branches | |
git push <remote location> <branch name // verfiy using git status> // used on client side | |
git fetch <remote location> <branch name // verfiy using git status>// used on client side | |
git pull <remote location> <branch name // verfiy using git status> // used on repo created on server | |
git clean -n -d <dir path> // will show the file will be removed | |
git clean -f -d <dir path> // will remove files | |
------------------------------------------------------------------------ | |
Update git branches from master | |
The First is a merge, but this creates an extra commit for the merge. | |
Checkout each branch | |
$ git checkout b1 | |
then merge | |
$ git merge origin/master | |
then push | |
$ git push origin master | |
Alternatively, you can do a rebase: | |
$ git rebase master | |
........................................................................ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment