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?do=
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,.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 operationgit log
: print log of commitgit remote add origin <url>
: Create a remote repository with location <url>.origin
is the name of the remote repositorygit push -u origin master
: push the content of the local repository master to the remote repository origin. The-u
option tells git to saveorigin
andmaster
name. As a consequence, the next call should begit push
git 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
.HEAD
is the lastcommit
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 repositorygit checkout – octocat.txt
: takes the fileoctocat.txt
from the remote repositorygit branch foo
: create a branch (a copy of the repository) with namefoo
git branch
: list the branches (master and foo)git checkout foo
: switches to branchfoo
git rm '*.txt
': remove all file with extension.txt
from the branchfoo
. To remove a directory:git rm -r <dir_name>
(changes can be committed withgit commit -m “message”
- To merge
foo
branch withmaster
git checkout master
to 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?do=
/web/htdocs/www.skenz.it/home/data/pages/cs/git.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1