User Tools

Site Tools


cs:git
Return to Home page
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


cs:git [2024/04/08 22:35] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== Git ======
 +Useful resources for git subversioning system
  
 +===== Example of git commands (client) =====
 +  - ''git init'': in a directory create a new repository
 +  - ''git status'': check the current status of the repository
 +  - ''git add <file_list>'': add <file_list> to the repository (files are added in the staging area, ''.git'' hidden folder)
 +     * ''git add '*.txt''': add all ''.txt'' file to the repository (staging area) in a while 
 +  - ''git commit -m "message"'': files are committed to the repository, providing a message that describes the commit operation
 +  - ''git log'': print log of commit
 +  - ''git remote add origin <url>'': Create a remote repository with location <url>. ''origin'' is the name of the remote repository
 +  - ''git push -u origin master'': push the content of the local repository **master** to the remote repository **origin**. The ''-u'' option tells git to save ''origin'' and ''master'' name. As a consequence, the next call should be ''git push''
 +  - ''git pull origin master'': pull the change from the remote repository **origin** to the local repository **master**
 +  - ''git diff HEAD'': differences between the master repository and our last ''commit''. ''HEAD'' is the last ''commit''
 +  - ''git diff --staged'': differences between committed files and //staged// files (i.e., the one added to the repository or modified, but not jet committed)
 +  - ''git reset <filename>'': remove filename from the repository
 +  - ''git checkout -- octocat.txt'': takes the file ''octocat.txt'' from the remote repository
 +  - ''git branch foo'': create a branch (a copy of the repository) with name ''foo''
 +  - ''git branch'': list the branches (master and foo)
 +  - ''git checkout foo'': switches to branch ''foo''
 +  - ''git rm '*.txt''': remove all file with extension ''.txt'' from the branch ''foo''. To remove a directory: ''git rm -r <dir_name>'' (changes can be committed with ''git commit -m "message"''
 +  - To merge ''foo'' branch with ''master''
 +     * ''git checkout master'' to change the repository
 +     * ''git merge foo'': does the merge
 +     * ''git branch -d foo'': deletes branch ''foo''
 +  - ''git push'': remember to push changes to the remote repository
 +
 +
 +Guide for using git: https://try.github.io/levels/1/challenges/1
 +
 +===== Setup git server =====
 +
 +https://www.linux.com/learn/tutorials/824358-how-to-run-your-own-git-server
 +
 +==== On the client ====
 +  - ''ssh git@apinda.polito.it "git init --bare /home/git/abc.git"'': creates the new remote repository
 +  - ''git clone git@apinda.polito.it:/home/git/abc.git'': copy the new repository locally
 +  - ''git add <files>''
 +  - ''git commit -m "message"''
 +  - ''git push origin master'': Le altre volte basta fare ''git push''
 +
 +==== Double commit and push ====
 +Sometimes, after a double ''commit'' followed by a ''push'', git returns an error. A possible way to resolve the error is running the following there commands:
 +<code bash>
 +git stash
 +git pull
 +git stash pop
 +</code>
 +
 +===== Resources =====
 +  * Git graphical clients for Linux: https://www.maketecheasier.com/6-useful-graphical-git-client-for-linux/
 +  * Git and emacs: https://www.emacswiki.org/emacs/Git
 +  * Emacs shortcut: https://www.emacswiki.org/emacs/VersionControl 

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/cs/git?do=diff
/web/htdocs/www.skenz.it/home/data/pages/cs/git.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki
Privacy Policy