Difference between revisions of "Git"

From wiki
Jump to navigation Jump to search
Line 20: Line 20:
 
;<code>git remote -v</code>
 
;<code>git remote -v</code>
 
:Show 'remote' configuration.
 
:Show 'remote' configuration.
 +
;<code>git status -v</code>
 +
:Show all difference between the current directory and the local repository.
 +
;<code>git add/rm <path></code>
 +
:Add or remove files from the list of files to be commited.
 +
;<code>git commit</code>
 +
:Commit changes (add/rm) to the local repository.
 +
;<code>git commit -a</code>
 +
:Commit all local changes to the local repository.
 +
;<code>git reset HEAD <path></code>
 +
:Reset commit status for <path>
 +
;<code>git push</code>
 +
:Send the repository remote<path>
 +
;<code>git pull</code>
 +
:Fetch all changes made remote<path>
  
 
==Local setup==
 
==Local setup==

Revision as of 21:00, 10 May 2018

Using the Bitbucket code repository with git.

Using Git

Here is a basic overview of how you can work with git@bitbucket works:

  • Create a "repository" (project) with a git hosting tool (like Bitbucket)
Add you public key in Settings - 'Access keys'
  • Copy (or clone) the repository to your local machine git clone <repoURL(replace https with ssh)>
  • Set push URL to https git remote set-url --push origin <SSHrepoURL>
  • Add a file to your local repo and "commit" (save) the changes git add <filenname>
  • "Push" your changes to your master branch git push
  • Make a change to your file with a git hosting tool and commit
  • "Pull" the changes to your local machine git pull
  • Create a "branch" (version), make a change, commit the change
  • Open a "pull request" (propose changes to the master branch)
  • "Merge" your branch to the master branch
git config --local -l
List your configuration for this repository (in the current directory).
git remote -v
Show 'remote' configuration.
git status -v
Show all difference between the current directory and the local repository.
git add/rm <path>
Add or remove files from the list of files to be commited.
git commit
Commit changes (add/rm) to the local repository.
git commit -a
Commit all local changes to the local repository.
git reset HEAD <path>
Reset commit status for <path>
git push
Send the repository remote<path>
git pull
Fetch all changes made remote<path>

Local setup

Install the git tools: apt-get install git

Initialize your user with:

a name: git config --global user.name "Your Name"
and email: git config --global user.email "user@domain.tld"

Set line endings correctly: git config --global core.autocrlf input

You homedir now has a .gitconfig files with this information

git config -l
List your configuration on user level