cs:git
Return to Home page
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
Table of Contents
Git
Useful resources for git subversioning system
Example of git commands (client)
git init: in a directory create a new repositorygit status: check the current status of the repositorygit add <file_list>: add <file_list> to the repository (files are added in the staging area,.githidden folder)git add '*.txt': add all.txtfile 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 operationgit log: print log of commitgit remote add origin <url>: Create a remote repository with location <url>.originis the name of the remote repositorygit push -u origin master: push the content of the local repository master to the remote repository origin. The-uoption tells git to saveoriginandmastername. As a consequence, the next call should begit pushgit pull origin master: pull the change from the remote repository origin to the local repository mastergit diff HEAD: differences between the master repository and our lastcommit.HEADis the lastcommitgit 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 repositorygit checkout – octocat.txt: takes the fileoctocat.txtfrom the remote repositorygit branch foo: create a branch (a copy of the repository) with namefoogit branch: list the branches (master and foo)git checkout foo: switches to branchfoogit rm '*.txt': remove all file with extension.txtfrom the branchfoo. To remove a directory:git rm -r <dir_name>(changes can be committed withgit commit -m “message”- To merge
foobranch withmastergit checkout masterto change the repositorygit merge foo: does the mergegit branch -d foo: deletes branchfoo
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
On the client
ssh git@apinda.polito.it “git init –bare /home/git/abc.git”: creates the new remote repositorygit clone git@apinda.polito.it:/home/git/abc.git: copy the new repository locallygit add <files>git commit -m “message”git push origin master: Le altre volte basta faregit 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:
git stash git pull git stash pop
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
/web/htdocs/www.skenz.it/home/data/pages/cs/git.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1
