Last active
June 13, 2017 09:22
-
-
Save reinislejnieks/2134565 to your computer and use it in GitHub Desktop.
git reference #git
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 config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" | |
git init // on directory starts to track files inside | |
git clone clone git://github.com/h5bp/html5-boilerplate.git mapesvards | |
git status | |
git add <filename/directory> | |
git commit | |
git commit -m "user authentication code added" | |
git commit -a // automatically stage every file that is already tracked before doing the commit, letting you skip the git add part | |
git rm <file> // deletes and stops tracking | |
git rm -r --cached . //remove all stgaged files | |
git reset --hard HEAD // reset all files to last commit | |
git checkout -- hello.rb /*reset for singe file 1.*/ | |
git checkout HEAD hello.rb /*reset for singe file 2.*/ | |
git mv file_from file_to // rename files | |
$ git revert HEAD // reverts files to most recent commit (if you performed wrong commit) | |
git config --global alias.co checkout // creates alias - shortcut | |
git co something | |
git gc // recompress archive for performance, slow, for large repositories | |
git add . // add every file to stage | |
git add *.js //add all js files | |
git add index.php // add index.php | |
git branch newIdea // create new branch | |
git checkout newIdea // switch to taht branch | |
// create new files, modify existing ones and then... | |
git add . // add everything to stage | |
git commit -m 'New killer idea' | |
git checkout master // switch back to master | |
git merge newIdea // while on another brach - master in this case | |
// everything on the newIdea branch is part of master branch now | |
git branch -d newIdea // delete newIdea branch | |
git 3 // shows logged commit history | |
git reset HEAD .gitignore // unset staged file | |
cls // clear screen | |
// with DROPBOX | |
Open up a terminal, and change directory to your project folder: | |
cd ~/Sites/my_killer_app | |
The next step is to clone your existing local repo into the shared dropbox folder: | |
git clone --bare . ~/Dropbox/shared_folder/my_killer_app.git | |
The --bare option tells git to not include the project files. Only those files needed to track the versioning are cloned (mainly those present in the .git/ folder). | |
Now you have sort of a remote repository. Although it's on your machine, it's remote to everyone else sharing the folder. But to make things work we need to add this "remote" location and give it an alias: | |
git remote add my_killer_app ~/Dropbox/shared_folder/my_killer_app.git | |
There! It's done. Now you can push your changes to the repository. And pull the changes on another machine with your dropbox account. Also people sharing the folder will be able to do the same. | |
Just for the sake of completeness, here's how you would make changes and commit them to the "remote" server: | |
You made changes to the code, now it's time to add and commit: | |
git commit -a -m "another commit example" | |
Nice! Now let push them to the "remote" server: | |
git push my_killer_app master | |
Piece of cake. | |
And here's how a different user sharing the folder would do to collaborate on your project: | |
Clone the repository: | |
git clone C:\Dropbox\shared_folder\my_killer_app.git | |
git clone -o gitexp2 C:\Users\reinis\Dropbox\gitesp.git | |
Add the alias to remote repository: | |
git remote add my_killer_app ~/Dropbox/shared_folder/my_killer_app.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment