Git notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 71: | Line 71: | ||
Clean up | Clean up | ||
=== taking all | === taking all branches from remote and sending them to another === | ||
ensure that you have defiend both source and destination in your local repo. | ensure that you have defiend both source and destination in your local repo. |
Revision as of 22:18, 24 November 2015
Tips and Tricks
when making a new repo that will "receive" stuff use --bare
ssh server user@server$ cd /data/gitroot user@server$ git init --bare mynewproject ssh desktop user@desktop$ cd /home/david/work user@desktop$ git init mynewproject user@desktop$ touch myfile && git add myfile && git commit -m "initial import" user@desktop$ git remote add origin ssh://user@server:/data/gitroot/mynewproject user@desktop$ git push -u origin master
If you do not "git init --bare projectname" on the server then you might get something like this:
david@keres ~ $ git push -u origin master Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 1.28 KiB | 0 bytes/s, done. Total 5 (delta 0), reused 0 (delta 0) 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 /data/gitroot/home ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '/data/gitroot/home'
Basics
get some code:
git clone username@gitserver:/srv/gitroot/ugo-project.git
branches
list branches
git branch
make a new branch
git branch <newbranchname>
switch between branches
git checkout <branchname>
for example to switch back to master:
git checkout master
Maintenance
Backup
Clean up
taking all branches from remote and sending them to another
ensure that you have defiend both source and destination in your local repo.
git remote -v source url (fetch) source url (push) destination url (fetch) destination url (push)
then do it like this:
git push destintion refs/remotes/source/*:refs/heads/*